Beispiel #1
0
        public ActionResult CreateSchedule(int doctorId, DateTime date)
        {
            var doctor = _doctorRepo.GetDoctorDetails(doctorId);

            _scheduleService.Create(date, doctor);
            return(RedirectToAction("Index", new { doctorId = doctorId }));
        }
        int ICrudService <Campaign> .Create(Campaign pEntity)
        {
            var lSchedules = pEntity.Schedules.ToList();

            pEntity.RemoveAllSchedules();

            iRepo.Add(pEntity);

            foreach (var sche in lSchedules)
            {
                if (sche.Id == 0)
                {
                    iSchServ.Create(sche);
                }
                else if (sche.Id > 0)
                {
                    iSchServ.Update(sche);
                }
                else
                {
                }
                pEntity.AddSchedule(iSchChecker, sche);
            }

            return(pEntity.Id);
        }
Beispiel #3
0
        public void CreateSchedule_UnderNormalConditions_ReturnsOkResponse()
        {
            //Arrange
            var scheduleToBeCreated = new ScheduleDto()
            {
                ScheduleId   = 6,
                InstructorId = 6,
                ClassId      = 6,
                RoomId       = 6,
                TrackId      = 6,
                ClassDate    = DateTime.Now.AddDays(5).Date
            };

            Mock.Arrange(() => _mockScheduleService.Create(scheduleToBeCreated))
            .Returns(scheduleToBeCreated)
            .OccursOnce();

            var scheduleController = new ScheduleController(_mockScheduleService)
            {
                Request = new HttpRequestMessage()
                {
                    RequestUri = new Uri("http://localhost/api/schedule")
                }
            };

            //Act
            var actual        = scheduleController.Post(scheduleToBeCreated) as CreatedNegotiatedContentResult <ScheduleDto>;
            var actualContent = actual.Content;

            //Assert
            Mock.Assert(_mockScheduleService);
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual, Is.TypeOf <CreatedNegotiatedContentResult <ScheduleDto> >());
            Assert.That(actualContent, Is.EqualTo(scheduleToBeCreated));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([FromBody] ScheduleContainer schedule)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            try
            {
                var id = await _service.Create(schedule);

                return(Ok(id));
            }
            catch (BussinessException ex) //Fail bussiness check
            {
                _logger.LogDebug(ex.Message);
                return(BadRequest(ex.Message));
            }
            catch (DbUpdateException ex)
            {
                Helper.Utility.LogException(ex, _logger);
                return(BadRequest("System error."));
            }
            catch (SqlException ex)
            {
                Helper.Utility.LogException(ex, _logger);
                return(BadRequest("System error."));
            }
        }
        public IActionResult Post([FromBody] ScheduleBaseModel model)
        {
            if (model == null)
            {
                return(BadRequest("schedule is null"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = _scheduleService.Create(model);

            if (result.IsSuccess)
            {
                var data = new
                {
                    ScheduleId = long.Parse(result.Message),
                    model.AvailableOn.Date,
                    model.Remark,
                    model.CategoryId
                };
                return(CreatedAtRoute("GetSchedule", new { id = data.ScheduleId }, data));
            }
            return(BadRequest(result));
        }
Beispiel #6
0
 public IHttpActionResult Post(ScheduleDto schedule)
 {
     using (_scheduleService)
     {
         var response = _scheduleService.Create(schedule);
         return(Created(new Uri(Request.RequestUri, $"{response.ScheduleId}"), response));
     }
 }
        public IActionResult CreateSchedule([FromBody] CreateScheduleViewModel createSchedule)
        {
            if (!_patientService.Exist(createSchedule.PatientId) && !_userService.Exist(createSchedule.UserId))
            {
                return(NotFound());
            }

            var scheduleDTO = ScheduleMapper.CreateScheduleVMtoDTO(createSchedule);

            _scheduleService.Create(scheduleDTO);

            return(Ok(ModelState));
        }
Beispiel #8
0
        public async Task <IActionResult> Post([FromBody] CreateScheduleDto schedule)
        {
            var listError = ValidPropertiesObject.ObjIsValid(schedule);

            if (listError.Count > 0 || schedule == null)
            {
                return(await ResponseNullOrEmpty(listError));
            }

            var result = _service.Create(schedule);

            return(await Response(result, _service.Validate()));
        }
        public ActionResult Create(ScheduleDTO model)
        {
            model.EkleyenId = Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name).Select(c => c.Value)
                                              .SingleOrDefault());
            model.Guid          = Guid.NewGuid();
            model.EklenmeZamani = DateTime.Now;
            model.Aktif         = true;
            model.Silindi       = false;
            model.KullaniciId   = Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name).Select(c => c.Value)
                                                  .SingleOrDefault());

            _scheduleService.Create(model);

            return(RedirectToAction("GetAppointments"));
        }
Beispiel #10
0
 public int AddSchedule(ScheduleDTO pDto)
 {
     iUoW.BeginTransaction();
     try
     {
         Schedule lSchedule = Mapper.Map <ScheduleDTO, Schedule>(pDto);
         iServ.Create(lSchedule);
         iUoW.Commit();
         return(lSchedule.Id);
     }
     catch (Exception)
     {
         iUoW.Rollback();
         throw;
     }
 }
        public IActionResult Create(int id, [FromBody] ScheduleDto scheduleDto)
        {
            if (Convert.ToInt32(User.Identity.Name) != id)
            {
                return(Unauthorized());
            }

            try
            {
                _scheduleService.Create(id, scheduleDto);
                return(Ok());
            }
            catch (ValidationException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Beispiel #12
0
        public IActionResult Create([FromBody] ScheduleCreateOrEtitRequest request)
        {
            var schedule = new Schedule();

            schedule.Day           = request.Day;
            schedule.FieldWorkerId = request.FieldWorkerId;
            schedule.SetAudit(CurrentLoggedUserId);

            var vendingMachineSchedules = new List <VendingMachineSchedule>();

            foreach (var id in request.VendingMachineIds)
            {
                var vendingMachineSchedule = new VendingMachineSchedule
                {
                    VendingMachineId = id
                };
                vendingMachineSchedule.SetAudit(CurrentLoggedUserId);
                vendingMachineSchedules.Add(vendingMachineSchedule);
            }

            schedule.VendingMachineSchedules = vendingMachineSchedules;

            var actionResult = new CustomActionResult
            {
                Successful = true,
                Message    = "Schedule was successfull created!"
            };

            try
            {
                var dbSchedule = _scheduleService.Create(schedule);
                actionResult.EntityId = dbSchedule.Id;
            }
            catch
            {
                actionResult.Successful = false;
                actionResult.Message    = "Create schedule was unsuccessfully, please try again!";

                return(Ok(actionResult));
            }

            return(Ok(actionResult));
        }
Beispiel #13
0
        public ActionResponseModel PostSchedule([FromBody] ScheduleModel scheduleModel)
        {
            ActionResponseModel response = new ActionResponseModel();

            response.Error = new List <string>();

            try
            {
                var emailAddress = User.Identity.Name;
                var user         = _userService.GetByEmail(emailAddress);

                if (_servicesService.Get(scheduleModel.ServiceId) == null)
                {
                    response.Error.Add("Service not found");
                }

                if (scheduleModel.DateTime < DateTime.Now)
                {
                    response.Error.Add("Schedule date is invalid");
                }

                if (response.Error.Count() > 0)
                {
                    response.Success = false;
                    response.Result  = null;
                }
                else
                {
                    _scheduleService.Create(user.Id, scheduleModel.ToDBModel());
                    response.Success = true;
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error.Add(ex.Message);
            }
            return(response);
        }
        public IActionResult Create(long CustomerId, long DoctorId, string Date)
        {
            CreateScheduleModel create = new CreateScheduleModel(Convert.ToDateTime(Date)
                                                                 , _customerService.GetCustomerById(CustomerId)
                                                                 , _doctorService.GetDoctorById(DoctorId));

            if (create.Invalid)
            {
                ViewData["CustomerError"] = create.Notifications
                                            .Where(w => w.Property == "Customer")?
                                            .FirstOrDefault()?
                                            .Message;
                ViewData["DoctorError"] = create.Notifications
                                          .Where(w => w.Property == "Doctor")?
                                          .FirstOrDefault()?
                                          .Message;

                return(View("New"));
            }

            ViewData["ScheduleView"] = _mapper.Map <ScheduleView>(_scheduleService.Create(create));
            return(View());
        }
        public async Task <IHttpActionResult> Create(CreateScheduleRq rq)
        {
            var rs = await _scheduleService.Create(rq);

            return(ApiJson(rs));
        }
Beispiel #16
0
        public IActionResult Post([FromBody] CreateScheduleParams parameters)
        {
            var newSchedule = _scheduleService.Create(_mapper.Map <Schedule>(parameters));

            return(Ok(_mapper.Map <ScheduleDTO>(newSchedule)));
        }