For work, we have specific types of records that are included, but each project has its own implementation. Columns etc. They differ from each other, but in general the process is the same (records are divided into batches, batches are assigned, batches are completed, batches are returned, batches are sent, etc.). Many of the columns are also common, but name changes sometimes occur (BatchId in one vs Id in another. [Column ("name") takes care of this problem).
This is currently what I have for implementing batch assignment functionality with the common components specified in the interface:
public interface IAssignment
{
...
T GetAssignmentRecord<T>(int UserId, int BatchId) where T : IAssignment;
List<T> GetAssignmentRecords<T>(int UserId) where T : IAssignment;
}
Now I have two projects that have a batch assignment. Due to the fact that they are executed in EntityFramework, assignment in namespace 1 and assignment in namespace2 are completely different things, but are connected by certain common components (identifier, assigned user, registered, etc.), which control all methods of their return .
I think my main question is that I am doing it wrong, and if there is a better way to achieve this, so that I can transfer data to my controllers, and so that the controllers look a bit like a project, having as much method work is processed automatically (first of all, for the “fix, fix everything” scenario to occur when I need to make updates).
Here is an example of how I am implementing the implementation for namespace1:
public class Assignment
{
...
public T GetAssignmentRecord<T>(int UserId, int BatchId) where T : IAssignment
{
var db = new Database1Context();
return (T) Convert.ChangeType(db.Assignment.Where(c => c.UserId == UserId && c.BatchId == BatchId && c.Assigned).First(), typeof(T));
}
}
In the controller:
Assignment assignment = new Assignment();
var record = assignment.GetAssignmentRecord<Assignment>(userid, batchid);
, , . Assignment, , . , , , , : " , framework, , " , , ".
? , ?