public static GroupsOfEmployeeModel EntityToModel(this GroupsOfEmployee entity, bool virtualActive = false) { try { GroupsOfEmployeeModel model = new GroupsOfEmployeeModel() { DepartmentId=entity.DepartmentId, Name=entity.Name, IsActive = entity.IsActive, Id = entity.Id }; if (virtualActive) { model.Department = entity.Department; model.Employees = entity.Employees; } return model; } catch (Exception) { return new GroupsOfEmployeeModel(); } }
public ActionResult GroupInsert(GroupsOfEmployeeModel model) { ViewBag.Departmanlar = _serviceDepartments.GetAll().Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList(); if (ModelState.IsValid) { _serviceGroupsOfEmployee.Insert(model.ModelToEnity(true)); } return RedirectToAction("GroupList"); }