private void SoftDelete(tblM_Project project) { if (project != null) { project.Status_FK = (int)RecordStatus.Deleted; } }
private void HardDelete(tblM_Project project) { if (project != null) { Db.tblM_Project.Remove(project); } }
public void Update(ProjectDTO projectDTO, DateTime dateStamp) { if (projectDTO == null) { throw new ArgumentNullException("Project model is null."); } tblM_Project project = projectFactory.CreateFromDbAndUpdateFromDTO(projectDTO, dateStamp); }
public tblM_Project Insert(ProjectDTO projectDTO, DateTime dateStamp) { if (projectDTO == null) { throw new ArgumentNullException("Project model is null."); } tblM_Project project = projectFactory.CreateFromDTO(projectDTO, dateStamp); return(Db.tblM_Project.Add(project)); }
public tblM_Project CreateFromDTO(ProjectDTO projectDTO, DateTime dateStamp) { if (projectDTO == null) { throw new ArgumentNullException("Project model is null."); } projectDTO.Status_FK = (int)RecordStatus.Active; projectDTO.CreatedBy = User.Username; projectDTO.CreatedDate = dateStamp; projectDTO.UpdatedBy = User.Username; projectDTO.UpdatedDate = dateStamp; tblM_Project project = projectDTO.ToObject <tblM_Project>(); return(project); }
public SaveResult <ProjectEntryModel> Save(ProjectDTO projectDTO, DateTime dateStamp) { ModelValidationResult validationResult = projectValidator.Validate(projectDTO); bool success = false; ProjectEntryModel model = null; if (validationResult.IsValid) { tblM_Project project = Insert(projectDTO, dateStamp); Db.SaveChanges(); success = true; model = projectEntryDataProvider.Get(project.Project_PK); } return(new SaveResult <ProjectEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully created." : "Validation error occured.", Model = model, ValidationResult = validationResult }); }
public DeleteResult <tblM_Project> Execute(int projectPK, DeleteMethod deleteMethod) { tblM_Project project = Db.tblM_Project.Find(projectPK); if (project == null) { return(new DeleteResult <tblM_Project>() { Success = false, Message = $"Id '{projectPK}' is not found.", Record = null }); } switch (deleteMethod) { case DeleteMethod.Soft: SoftDelete(project); break; case DeleteMethod.Hard: HardDelete(project); break; default: break; } Db.SaveChanges(); return(new DeleteResult <tblM_Project>() { Success = true, Message = $"Project with Id '{projectPK}' successfully deleted.", Record = project }); }