コード例 #1
0
 public void Update(SOWTrackDTO sowTrackDTO, DateTime dateStamp)
 {
     if (sowTrackDTO == null)
     {
         throw new ArgumentNullException("SOWTrack model is null.");
     }
     tblT_SOWTrack sowTrack = sowTrackFactory.CreateFromDbAndUpdateFromDTO(sowTrackDTO, dateStamp);
 }
コード例 #2
0
        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));
        }
コード例 #3
0
        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,
            });
        }
コード例 #4
0
        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,
            });
        }
コード例 #5
0
        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
            });
        }
コード例 #6
0
        public SOWTrackDTO GetByPrimaryKey(int primaryKey)
        {
            SOWTrackDTO record = GetQuery().FirstOrDefault(sowTrack => sowTrack.SOWTrack_PK == primaryKey);

            return(record);
        }