Esempio n. 1
0
 public bool Insert(HolidayParam holidayParam)
 {
     if (holidayParam != null)
     {
         status = _holidayRepository.Insert(holidayParam);
     }
     return(status);
 }
Esempio n. 2
0
        public ActionResult <CommonResponeModel> Create(HolidayCreateRequestModel model)
        {
            var databaseObject = model.MapTo <Holiday>();

            //empty code
            if (string.IsNullOrEmpty(databaseObject.Code))
            {
                var code = entityCenterRepository.GetCodeByEntity(nameof(Holiday));

                if (string.IsNullOrEmpty(code))
                {
                    Result = new ErrorResult(ActionType.Insert, AppGlobal.MakeCodeError);
                    return(GetCommonRespone());
                }

                databaseObject.Code = code;
            }

            //check exist in db
            if (holidayRepository.IsExistCode(databaseObject.Code))
            {
                Result = new ErrorResult(ActionType.Insert, AppGlobal.ExistCodeError);
                return(GetCommonRespone());
            }

            databaseObject.InitBeforeSave(RequestUsername, InitType.Create);
            int result = holidayRepository.Insert(databaseObject);

            if (result > 0)
            {
                Result = new SuccessResultFactory().Factory(ActionType.Insert);
            }
            else
            {
                Result = new ErrorResultFactory().Factory(ActionType.Insert);
            }

            return(GetCommonRespone());
        }
Esempio n. 3
0
        public async Task <int> Handle(InsertHolidayCommand request, CancellationToken cancellationToken)
        {
            var holiday  = new DonVo.CQRS.Standard21.Domain.Model.Company.Holiday(request.Date);
            var holidays = await HolidayRepository.Select();

            if (holidays.Any(h => h.Date.Year == holiday.Date.Year && h.Date.Month == holiday.Date.Month && h.Date.Day == holiday.Date.Day))
            {
                throw new ArgumentOutOfRangeException("Date", "Holiday already exist.");
            }
            var id = await HolidayRepository.Insert(holiday);

            await Mediator.Publish(new HolidayInsertedEvent { Id = holiday.Id });

            return(id);
        }
Esempio n. 4
0
 public bool Insert(HolidayVM holidayVM)
 {
     return(iHolidayRepository.Insert(holidayVM));
 }