public IActionResult Roosters(RoosterModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            if (model == null)
            {
                return(Roosters());
            }

            var rooster = new Rooster
            {
                UserId      = model.SelectedUser,
                StartShift  = model.StartShift,
                EndShift    = model.EndShift,
                RoosterDate = model.RoosterDate
            };

            _scheduleService.Create(rooster);

            TempData["message"] = new AlertMessage {
                CssClass = "alert-success", Id = string.Empty, Title = "Rooster aangemaakt.", Message = $"Het rooster voor {model.RoosterDate} is succesvol aangemaakt!"
            };

            return(Roosters());
        }
        public void Startup()
        {
            var connection = new SqliteConnection("Filename=:memory:");

            connection.Open();
            service = ScheduleService.Create(b => b.UseSqlite(connection));
        }
        public IActionResult OnPost()
        {
            var form = HttpContext.Request.Form;

            var userTest = HttpContext.Session.GetString("User");

            Console.Write(userTest);

            var schedule = new ScheduleModel
            {
                Date      = form["date"],
                Time      = form["time"],
                Duration  = form["duration"],
                EventName = form["eventname"],
                EventType = form["eventtype"],
                Location  = form["location"],
                UsagePlan = form["usage"],
                User      = HttpContext.Session.GetString("User")
            };

            _scheduleService.Create(schedule);

            var bookingId = schedule.Id;

            Success = $"Booking with ID {bookingId} has been successfully registered.";
            return(RedirectToPage("/schedule/overview"));
        }
Exemplo n.º 4
0
        public void CreateSchedule_UnderNormalConditions_AddScheduleToScheduleList()
        {
            //arrange
            var originalCountOfSchedules = _scheduleList.Count;

            var scheduleToCreate = new Schedule()
            {
                InstructorId = 6,
                ClassId      = 6,
                RoomId       = 6,
                TrackId      = 6,
                ScheduleId   = 6,
                ClassDate    = DateTime.Now
            };

            var mockRepo = Mock.Create <IScheduleRepository>();

            Mock.Arrange(() => mockRepo.Create(Arg.IsAny <Schedule>()))
            .DoInstead(() => _scheduleList.Add(scheduleToCreate))
            .OccursOnce();

            _scheduleService = new ScheduleService(mockRepo);

            //act
            _scheduleService.Create(scheduleToCreate.ConvertToScheduleDto());
            var actualCountOfSchedules = _scheduleList.Count;

            //assert
            Mock.Assert(mockRepo);
            Assert.That(actualCountOfSchedules, Is.EqualTo(originalCountOfSchedules + 1));
        }
Exemplo n.º 5
0
        public static ScheduleConsole Create()
        {
            var service = ScheduleService.Create(
                b => b.UseNpgsql("host=localhost;database=schedule;username=schedule;password=schedule;"));
            var commander = new ConsoleCommander(service, RequestInput, Console.WriteLine);

            return(new ScheduleConsole(commander));
        }
Exemplo n.º 6
0
 public IActionResult Create(GroupSheduleModel groupSheduleModel)
 {
     return(Ok(_scheduleService.Create(groupSheduleModel)));
 }
Exemplo n.º 7
0
        public ActionResult <Schedule> Create(Schedule schedule)
        {
            _scheduleService.Create(schedule);

            return(CreatedAtRoute("GetSchedule", new { id = schedule.Id.ToString() }, schedule));
        }