public void Test_CreateSchedule_Adds_Range()
        {
            claimId = "ID123";

            scheduleService.CreateSchedule(claimId, DateTime.Now);

            mockScheduleDbSet.Verify(x => x.AddRange(It.IsAny <List <Schedule> >()), Times.AtMostOnce);
        }
Beispiel #2
0
        public IActionResult Selection(string Selections)
        {
            List <SelectionsViewModel> selections = PublicMethod.JsonDeSerialize <List <SelectionsViewModel> >(Selections);
            bool isFinish;

            _service.CreateBooking(selections, out isFinish);
            if (!isFinish)
            {
                return(RedirectToAction("Index"));
            }
            foreach (MemberBooking item in _service.Model.Bookings.ToList())
            {
                MemberBalance balance = _service.Model.Balances.FirstOrDefault(x => x.MemberId == item.MemberId && x.AvailableBalances > 0);
                bool          isSuccess;

                if (balance != null && item.Status == BookingStatus.Booking)
                {
                    _service.MakePair(item, out isSuccess);
                    if (isSuccess)
                    {
                        _service.CreateSchedule(item);
                    }
                    else
                    {
                        _service.Model.Bookings.Remove(item);
                    }
                }
            }
            return(RedirectToAction("Schedule", "Schedule"));
        }
        public async Task <IActionResult> Create([FromBody] Schedule schedule)
        {
            ServiceResponse <Schedule> serviceResponse = new ServiceResponse <Schedule>();

            if (schedule == null)
            {
                _logger.LogError("schedule object sent from client is null.");
                serviceResponse.IsSuccess = false;
                serviceResponse.Message   = "schedule object sent from client is null";
                return(BadRequest(serviceResponse));
            }

            if (!ModelState.IsValid)
            {
                _logger.LogError("Invalid schedule object sent from client.");
                serviceResponse.IsSuccess = false;
                serviceResponse.Message   = "Invalid schedule object sent from client.";
                return(BadRequest(serviceResponse));
            }
            serviceResponse = await _scheduleService.CreateSchedule(schedule);

            if (serviceResponse == null)
            {
                return(BadRequest(serviceResponse));
            }

            serviceResponse.Message = "Schedule Successfully Created";
            return(Ok(serviceResponse));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([FromBody] CreateScheduleModel createScheduleModel)
        {
            var userId = int.Parse(HttpContext.User.Identity.Name);

            await _scheduleService.CreateSchedule(userId, createScheduleModel);

            return(NoContent());
        }
Beispiel #5
0
        public async Task <IActionResult> Create(CreateSchduleRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _scheduleService.CreateSchedule(request);

            if (result.IsSuccessed == false)
            {
                return(BadRequest(result));
            }
            return(Ok(result));
        }
        public async Task <IActionResult> StartSeason(int id, int leagueId)
        {
            Season season = await seasonRepository.FindBySeasonIdAndLeagueId(id, leagueId);

            var matchdays = scheduleService.CreateSchedule(season.Teams);

            await saveMatchdays(matchdays);

            season.Matchdays = matchdays;
            season.Status    = SeasonStatus.Ongoing;
            await seasonRepository.UpdateSeason(season);

            return(RedirectToAction(nameof(Index), new { leagueId }));
        }
        public IActionResult Post(ScheduleModel model)
        {
            model.UserProfileId = User.Identity.GetUserProfileId() ?? default(long);

            if (ModelState.IsValid)
            {
                var dates = model.RecurrenceRule != null?RecurrenceHelper.GetRecurrenceDateTimeCollection(model.RecurrenceRule, model.StartDate) : null;

                var result = _scheduleService.CreateSchedule(model, dates);

                return(Json(result));
            }

            return(PartialView("_CreatePartial", model));
        }
        public JsonResult AddSchedule(ScheduleViewModel schedule)
        {
            //db.Schedules.Add(schedule);
            //db.SaveChanges();
            //var mysche = db.Schedules.Where(b => b.Day == schedule.Day).Where(c => c.Time == schedule.Time).FirstOrDefault().Id;
            //return Json(mysche, JsonRequestBehavior.AllowGet);

            var sched = Mapper.Map <ScheduleViewModel, Schedule> (schedule);

            scheduleService.CreateSchedule(sched);
            scheduleService.SaveSchedule();
            var mysche = db.Schedules.Where(b => b.Day == schedule.Day).Where(c => c.Time == schedule.Time).FirstOrDefault().Id;

            return(Json(mysche, JsonRequestBehavior.AllowGet));
        }
Beispiel #9
0
        public async Task <object> CreateSchedule(ScheduleDtoForImportExcel entity)
        {
            return(Ok(await _scheduleService.CreateSchedule(entity)));
            // if (await _ingredientService.CheckExists(entity.ID))
            //     return BadRequest("Ingredient ID already exists!");
            // if (await _ingredientService.CheckBarCodeExists(entity.Code))
            //     return BadRequest("Ingredient Barcode already exists!");
            // if (await _ingredientService.CheckExistsName(entity.Name))
            //     return BadRequest("Ingredient Name already exists!");
            // entity.CreatedDate = DateTime.Now.ToString("MMMM dd, yyyy HH:mm:ss tt");
            // if (await _ingredientService.Add1(entity))
            // {
            //     return NoContent();
            // }

            // throw new Exception("Creating the brand failed on save");
        }
 public ActionResult <ScheduleModel> CreateSchedule([FromBody] ScheduleModel ScheduleModel)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ScheduleModel));
         }
         var url             = HttpContext.Request.Host;
         var createdSchedule = _Scheduleservice.CreateSchedule(ScheduleModel);
         return(CreatedAtRoute("GetSchedule", new { ScheduleId = createdSchedule.Id }, createdSchedule));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, $"Something happend: {ex.Message}"));
     }
 }
Beispiel #11
0
 public Task HandleAsync(CreateSchedule command)
 => _handler
 .Handle(async() =>
 {
     _logger.LogInformation($"[{nameof(CreateScheduleHandler)}] - Creating new schedule (days: {string.Join(',',command.DaysOfWeek)}, time: {command.StartTime}).");
     await _scheduleService.CreateSchedule(command.StartTime, command.DaysOfWeek);
 })
 .OnSuccess(async() =>
 {
     _logger.LogInformation($"[{nameof(CreateScheduleHandler)}] - Schedule created.");
     await Task.CompletedTask;
 })
 .OnCustomError(async(ex) =>
 {
     _logger.LogError($"[{nameof(CreateScheduleHandler)}] - Custom error occurred while creating schedule. {ex.Message}");
     await Task.FromException(ex);
 })
 .OnError(async(ex) =>
 {
     _logger.LogError($"[{nameof(CreateScheduleHandler)}] - Error occurred while creating schedule. Message: {ex.Message}. StackTrace: {ex.StackTrace}");
     await Task.FromException(ex);
 })
 .ExecuteAsync();
Beispiel #12
0
        public async Task <ActionResult> CreateSchedule([FromBody] Schedule schedule)
        {
            await _scheduleService.CreateSchedule(schedule);

            return(Ok(true));
        }