Exemplo n.º 1
0
        public async void CreateScheduleTest()
        {
            var taskRepository  = new TaskRepository();
            var habitRepository = new HabitRepository();
            var service         = new ScheduleService(taskRepository, habitRepository);

            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            await service.CreateSchedule("eda1df41-a346-48dc-81ea-1f3288fcd58a", "d6a79a07-8f98-40fd-b1c2-d6269b3d6918");

            Assert.True(true);
        }
Exemplo n.º 2
0
        public ApiResponse <object> CreateSchedule(Guid token, [FromBody] Schedule schedule)
        {
            ApiResponse <DataModels.User> response = _vkAuthService.CheckToken(token);

            if (!response.Ok)
            {
                return(new ApiResponse <object>(response.ErrorMessage));
            }

            return(_vkScheduleService.CreateSchedule(response.Data, schedule));
        }
Exemplo n.º 3
0
        public IActionResult Post([FromBody] ScheduleViewModel svm)
        {
            if (string.IsNullOrEmpty(svm.TimeZoneId))
            {
                return(BadRequest("A TimeZoneId must be specified for the schedule"));
            }

            var stzi = TimeZoneInfo.FindSystemTimeZoneById(svm.TimeZoneId);

            _scheduleService.CreateSchedule(svm, stzi);

            return(StatusCode(201));
        }
Exemplo n.º 4
0
        public IActionResult Create(CreateScheduleModel model)
        {
            var validationResult = _service.ValidateCreateSchedule(User, model);

            if (!validationResult.Valid)
            {
                return(BadRequest(validationResult.Result));
            }
            var entity = _service.CreateSchedule(model);

            context.SaveChanges();
            return(Created($"/{ApiEndpoint.SCHEDULE_API}?id={entity.Id}",
                           new AppResultBuilder().Success(entity.Id)));
        }
Exemplo n.º 5
0
        public IActionResult Create(ScheduleCreateViewModal model)
        {
            var available = _sheduleService.GetAvailableRoom(model).ToList();

            if (available.Count() == 0)
            {
                var UserId = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                _sheduleService.CreateSchedule(model, UserId);

                var data = GetItems(null, null);

                return(PartialView("ItemsTable", data));
            }
            else
            {
                var response = "<br />";
                foreach (var item in available)
                {
                    response = response + "Title: " + item.Title + " Start: " + item.TimeStart.ToString("dd/MM/yyyy HH:mm:ss") + " End: " + item.TimeEnd.ToString("dd/MM/yyyy HH:mm:ss") + "<br />";
                }
                return(BadRequest("There are already conflicting times for the Requested schedule!" + response));
            }
        }