public void Update(SOWTrackDTO sowTrackDTO, DateTime dateStamp) { if (sowTrackDTO == null) { throw new ArgumentNullException("SOWTrack model is null."); } tblT_SOWTrack sowTrack = sowTrackFactory.CreateFromDbAndUpdateFromDTO(sowTrackDTO, dateStamp); }
public tblT_SOWTrack Insert(SOWTrackDTO sowTrackDTO, DateTime dateStamp) { if (sowTrackDTO == null) { throw new ArgumentNullException("SOWTrack model is null."); } tblT_SOWTrack sowTrack = sowTrackFactory.CreateFromDTO(sowTrackDTO, dateStamp); return(Db.tblT_SOWTrack.Add(sowTrack)); }
private SOWTrackEntryModel GetCreateStateModel() { SOWTrackEntryFormData formData = new SOWTrackEntryFormData(); List <Control> formControls = CreateFormControls(0); SOWTrackDTO sowTrackDTO = new SOWTrackDTO(); return(new SOWTrackEntryModel() { FormData = formData, FormControls = formControls, Model = sowTrackDTO, }); }
private SOWTrackEntryModel GetUpdateStateModel(int sowTrackPK) { SOWTrackEntryFormData formData = new SOWTrackEntryFormData(); List <Control> formControls = CreateFormControls(sowTrackPK); SOWTrackDTO sowTrackDTO = sowTrackQuery.GetByPrimaryKey(sowTrackPK); if (sowTrackDTO == null) { throw new KairosException($"Record with primary key '{sowTrackDTO.SOWTrack_PK}' is not found."); } return(new SOWTrackEntryModel() { FormData = formData, FormControls = formControls, Model = sowTrackDTO, }); }
public SaveResult <SOWTrackEntryModel> Save(SOWTrackDTO sowTrackDTO, DateTime dateStamp) { ModelValidationResult validationResult = sowTrackValidator.Validate(sowTrackDTO); bool success = false; SOWTrackEntryModel model = null; if (validationResult.IsValid) { success = true; Update(sowTrackDTO, dateStamp); Db.SaveChanges(); model = sowTrackEntryDataProvider.Get(sowTrackDTO.SOWTrack_PK); } return(new SaveResult <SOWTrackEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.", Model = model, ValidationResult = validationResult }); }
public SOWTrackDTO GetByPrimaryKey(int primaryKey) { SOWTrackDTO record = GetQuery().FirstOrDefault(sowTrack => sowTrack.SOWTrack_PK == primaryKey); return(record); }