public async Task <Unit> Handle(DeleteHolidayCommand request, CancellationToken cancellationToken) { var holiday = await HolidayRepository.Get(request.Id); if (holiday == null) { throw new ArgumentOutOfRangeException("Holiday does not exist."); } await HolidayRepository.Delete(holiday); await Mediator.Publish(new HolidayDeletedEvent { Id = holiday.Id }); return(await Unit.Task); }
public ActionResult <CommonResponeModel> GetAll() { Data = holidayRepository.Get().ToList(); Result = new SuccessResultFactory().Factory(ActionType.Select); return(GetCommonRespone()); }
public List <Holiday> Get() { return(_holidayRepository.Get().ToList()); }
public ActionResult Get(int id) { var apiResult = TryExecute(() => _holidayRepository.Get(id), "Holiday fetched sucessfully"); return(Json(apiResult, JsonRequestBehavior.AllowGet)); }
public IQueryable <Holiday> GetAll() { return(_repository.Get(filter => filter.Date >= DbFunctions.TruncateTime(DateTime.Now)).OrderBy(p => p.Date)); }
public List <Holiday> Get() { return(iHolidayRepository.Get()); }
public IActionResult Index(FormValue model) { if (model == null) { throw new Exception(); } DateTime checkOutDate = DateTime.Parse(model.StartDate); DateTime returnDate = DateTime.Parse(model.EndDate); int countryId = Convert.ToInt32(model.Country); if (checkOutDate > returnDate) { throw new Exception(); } List <Week> weekends = weekendRepository.FindBy(x => x.CountryId == countryId).ToList(); if (weekends == null) { throw new Exception(); } List <Holiday> holidays = holidayRepository.FindBy(x => x.CountryId == countryId).ToList(); int dayCount = 0; for (DateTime date = checkOutDate; date < returnDate; date = date.AddDays(1)) { var continueWeekend = weekends.Where(x => x.Code == (int)date.DayOfWeek).ToList(); if (continueWeekend.Count == 0) { dayCount++; } Holiday holiday = holidayRepository.Get(x => x.CountryId == countryId && x.StartDate == date); if (holiday != null && holiday.Duration != 0) { returnDate.AddDays(holiday.Duration); } } decimal amount = 5, totalAmount = decimal.Zero; bool success = true; string symbol = string.Empty; if (dayCount > 10) { totalAmount = (dayCount - 10) * amount; success = false; Currency currency = currencyRepository.Get(x => x.CountryId == countryId); if (currency != null) { symbol = currency.Symbol; } } FormValue result = new FormValue() { Days = dayCount, Amount = totalAmount, Symbol = symbol, StartDate = model.StartDate, EndDate = model.EndDate }; ViewBag.result = new ApiResponse() { success = success }; return(View(result)); }