public static List <AssignmentsViewModel> ConvertModelToVM(SystemDbContext context, List <Assignments> assign) { List <AssignmentsViewModel> list = new List <AssignmentsViewModel>(); foreach (var item in assign) { AssignmentsViewModel assignment = new AssignmentsViewModel(context); assignment._EmployeeName = assignment.EmployeeName(item.EmpId); assignment._TaskName = assignment.TasksName(item.TaskId); assignment._AssignmentId = item.AssignmentId; list.Add(assignment); } return(list); }
public static Assignments ConvertViewModel(AssignmentsViewModel vm) { if (vm.Assignee.AssignmentId != 0) { return(new Assignments { AssignmentId = vm.Assignee.AssignmentId, EmpId = vm.Assignee.EmpId, TaskId = vm.Assignee.TaskId }); } else { return(new Assignments { EmpId = vm.Assignee.EmpId, TaskId = vm.Assignee.TaskId }); } }