Beispiel #1
0
        public SaveResult <AreaEntryModel> Save(AreaDTO areaDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = areaValidator.Validate(areaDTO);
            bool           success = false;
            AreaEntryModel model   = null;

            if (validationResult.IsValid)
            {
                success = true;
                UpdateArea(areaDTO, dateStamp);
                Db.SaveChanges();
                model = areaEntryDataProvider.Get(areaDTO.Area_PK);
            }

            return(new SaveResult <AreaEntryModel>
            {
                Success = success,
                Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.",
                Model = model,
                ValidationResult = validationResult
            });
        }
Beispiel #2
0
        public tblM_Area CreateFromDbAndUpdateFromDTO(AreaDTO areaDTO, DateTime dateStamp)
        {
            tblM_Area area;

            if (areaDTO == null)
            {
                throw new ArgumentNullException("Area model is null.");
            }
            area = Db.tblM_Area.Find(areaDTO.Area_PK);
            if (area == null)
            {
                throw new KairosException($"Record with key '{areaDTO.Area_PK}' is not found.");
            }

            area.UpdateValueFrom(areaDTO, "Area_PK", "Status_FK");
            areaDTO.CreatedBy   = area.CreatedBy;
            areaDTO.CreatedDate = area.CreatedDate;
            area.UpdatedBy      = areaDTO.UpdatedBy = User.Username;
            area.UpdatedDate    = areaDTO.UpdatedDate = dateStamp;

            return(area);
        }
Beispiel #3
0
        public AreaDTO GetByTitle(string title)
        {
            AreaDTO record = GetQuery().FirstOrDefault(area => area.Title == title);

            return(record);
        }
Beispiel #4
0
        public AreaDTO GetByPrimaryKey(int primaryKey)
        {
            AreaDTO record = GetQuery().FirstOrDefault(area => area.Area_PK == primaryKey);

            return(record);
        }