Beispiel #1
0
        public ActionResult Save(ScheduleAdminView model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Edit", model));
            }

            try
            {
                if (model.Id == 0)
                {
                    _scheduleServise.Add(model);
                }
                else
                {
                    _scheduleServise.Update(model);
                }
            }
            catch (ItemAlreadyExistException)
            {
                ModelState.AddModelError("MovieId", "Item with this value already exists.");
                ModelState.AddModelError("SessionId", "Item with this value already exists.");
                ModelState.AddModelError("Date", "Item with this value already exists.");
            }


            return(View("Edit", model));
        }
Beispiel #2
0
        public IActionResult Add(ScheduleAddDTO scheduleAddDTO)
        {
            Job             job       = _mapper.Map <Job>(scheduleAddDTO.Job);
            List <Employee> employees = _mapper.Map <List <Employee> >(scheduleAddDTO.Employees);

            _scheduleService.Add(scheduleAddDTO.Date, job, employees);
            return(StatusCode(201));
        }
Beispiel #3
0
 public IActionResult Post([FromBody] Schedule newSchedule)
 {
     try
     {
         _scheduleService.Add(newSchedule);
     }
     catch (System.Exception ex)
     {
         ModelState.AddModelError("AddSchedule", ex.GetBaseException().Message);
         return(BadRequest(ModelState));
     }
     return(CreatedAtAction("Get", new { Id = newSchedule.Id }, newSchedule));
 }
Beispiel #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     schedule.ScheduleName = tbxName.Text.Trim();
     schedule.ScheduleDesc = rTbxDesc.Text.Trim();
     try
     {
         ValidationTool.Validate(new ScheduleValidator(), schedule);
         scheduleService.Add(schedule, Session.currentUser);
         MessageBox.Show("Çalışma Programı başarıyla oluşturuldu.", "Başarılı!");
         this.Close();
     } catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Hata!");
     }
 }
        public IActionResult CreateSchedule(Schedule schedule)
        {
            if (ModelState.IsValid)
            {
                var newSchedule = new Schedule
                {
                    Morning   = schedule.Morning,
                    Afternoon = schedule.Afternoon,
                    Evening   = schedule.Evening,
                    DoctorID  = schedule.DoctorID
                };

                _scheduleService.Add(schedule);
                return(RedirectToAction(nameof(ListSchedule)));
            }
            else
            {
                return(View());
            }
        }
Beispiel #6
0
        public ActionResult Add(ScheduleAddModel model)
        {
            if (!ModelState.IsValid || !model.InitialDatesIsValid(ModelState))
            {
                return(View(model));
            }

            if (!User.IsInRole(Roles.Admin))
            {
                model.DispatcherId = User.Identity.GetUserIdInt();
            }

            var response = _scheduleService.Add(Mapper.Map <ScheduleModel>(model), model.DepartureDates, model.DestinationDates);

            if (!response.IsSuccessful)
            {
                ModelState.AddModelError("", response.Message);
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }
 public void Add(ScheduleEntryDto scheduleDto)
 {
     scheduleService.Add(scheduleDto);
 }