Beispiel #1
0
        public async Task <IActionResult> Post(ScheduleDto schedule)
        {
            if (schedule == null)
            {
                return(null);
            }
            await _entityService.CreateAsync(schedule);

            return(this.StatusCode(StatusCodes.Status200OK));
        }
        public async Task Create_ShouldCallRepository()
        {
            Schedule entity            = A.Fake <Schedule>();
            var      cancellationToken = new CancellationTokenSource().Token;

            await _service.CreateAsync(entity, cancellationToken);

            A.CallTo(() => _repository.Create(entity, cancellationToken))
            .MustHaveHappenedOnceExactly();
        }
        public async System.Threading.Tasks.Task <ActionResult> Add(Models.AdvancedScheduleAddVM model)
        {
            IScheduleService scheduleService = DependencyUtils.Resolve <IScheduleService>();

            if (ModelState.IsValid)
            {
                int dayFilter  = 0;
                int timeFilter = 0;
                foreach (var item in model.DayFilter)
                {
                    dayFilter += item;
                }
                foreach (var item in model.TimeFilter)
                {
                    timeFilter += item;
                }
                IScenarioService scenarioService = DependencyUtils.Resolve <IScenarioService>();
                var schedule = new Data.Models.Entities.Schedule
                {
                    ScenarioID = model.ScenarioID,
                    DeviceID   = model.DeviceID,
                    LayoutID   = scenarioService.GetLayoutIDById(model.ScenarioID),
                    DayFilter  = dayFilter,
                    TimeFilter = timeFilter,
                    Priority   = model.Priority,
                    isEnable   = model.isEnable,
                };
                await scheduleService.CreateAsync(schedule);

                Session.Clear();
                Session["ADD_RESULT"] = true;
                return(new ContentResult
                {
                    Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "AdvancedScheduling")),
                    ContentType = "text/html"
                });
            }
            return(View("Form", model));
        }
        public async Task <IActionResult> CreateAsync(ScheduleDTO entity)
        {
            await _scheduleService.CreateAsync(entity);

            return(Ok());
        }
Beispiel #5
0
 public async Task HandleAsync(CreateSchedule command)
 {
     await _scheduleService.CreateAsync(command.Id, command.Title, command.Description, command.TimeStart,
                                        command.TimeEnd, command.Location, command.CreatorId, command.Type, command.Status);
 }