public static PermitsModel EntityToModel(this Permits entity, bool virtualActive = false) { try { PermitsModel model = new PermitsModel() { EmployeeId = entity.EmployeeId, EndDate = entity.EndDate, PermitTypeId = entity.PermitTypeId, StartingDate = entity.StartingDate, IsActive = entity.IsActive, Id = entity.Id }; if (virtualActive) { model.PermitType = entity.PermitType; model.Employee = entity.Employee; } return model; } catch (Exception) { return new PermitsModel(); } }
public ActionResult PermitInsert(PermitsModel permitsModel) { Permits permit = permitsModel.ModelToEnity(); permit.IsActive = true; _servicePermits.Insert(permit); return RedirectToAction("PermitList"); }
public ActionResult PermitEdit(PermitsModel permits) { Permits permit = permits.ModelToEnity(true); permit.IsActive = true; _servicePermits.Update(permit); return RedirectToAction("PermitList"); }