예제 #1
0
        public void Create(HolidayTypeModel model, out Guid holidayTypeId)
        {
            if (this._repoHolidayType.Query().Filter(x => x.code == model.code).Get().Any())
            {
                throw new Exception(model.code + " is already exists");
            }
            var currentUserId = this.GetCurrentUserId();
            var ins           = this._repoHolidayType.PrepareEntity(model)
                                .MatchAllDataField()
                                .SetValue(x => x.updatedBy, currentUserId)
                                .Insert()
                                .GetEntity();

            this._unitOfWork.Save();
            holidayTypeId = ins.id;
        }
예제 #2
0
        public ActionResult HolidayTypeCRUD([DataSourceRequest] DataSourceRequest request
                                            , UpdateType updateType
                                            , HolidayTypeModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                try
                {
                    switch (updateType)
                    {
                    case UpdateType.Create:
                        Guid holidayTypeId;
                        this._HolidayTypeService.Create(model, out holidayTypeId);
                        model.id = holidayTypeId;
                        break;

                    case UpdateType.Update:
                        this._HolidayTypeService.Update(model);
                        break;

                    case UpdateType.Destroy:
                        this._HolidayTypeService.Delete(model.id.Value);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    this.AddModelError(ex);
                }
            }
            if (model.id.HasValue && updateType != UpdateType.Destroy)
            {
                model = this._HolidayTypeService.GetById(model.id.Value);
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
예제 #3
0
        public void Update(HolidayTypeModel model)
        {
            var upt = this._repoHolidayType.Find(model.id);

            if (upt.code != model.code)
            {
                if (this._repoHolidayType.Query().Filter(x => x.code == model.code).Get().Any())
                {
                    throw new Exception(model.code + " is already exists");
                }
                upt.code = model.code;
            }
            upt.description = model.description;

            upt.code        = model.code;
            upt.description = model.description;
            upt.rateWork    = model.rateWork;
            upt.rateNotWork = model.rateNotWork;

            upt.updatedBy   = this.GetCurrentUserId();
            upt.updatedDate = DateTime.Now;
            this._repoHolidayType.Update(upt);
            this._unitOfWork.Save();
        }