コード例 #1
0
ファイル: ScheduleService.cs プロジェクト: war-man/SmartKiosk
        public Schedule CreateSchedule(CreateScheduleModel model)
        {
            var entity = model.ToDest();

            PrepareCreate(entity);
            return(context.Schedule.Add(entity).Entity);
        }
コード例 #2
0
 public ScheduleModel Create(CreateScheduleModel model)
 {
     try
     {
         if (model.Invalid)
         {
             return(default);
コード例 #3
0
        public async Task <IActionResult> Create([FromBody] CreateScheduleModel createScheduleModel)
        {
            var userId = int.Parse(HttpContext.User.Identity.Name);

            await _scheduleService.CreateSchedule(userId, createScheduleModel);

            return(NoContent());
        }
コード例 #4
0
 public static Schedule MapFromCreateScheduleModel(int userId, CreateScheduleModel model)
 {
     return(new Schedule
     {
         Description = model.Description,
         UserId = userId,
         ScheduleDate = model.ScheduleDate
     });
 }
        public async Task ScheduleAppointment(CreateScheduleModel model, CancellationToken cancellationToken)
        {
            model.ArrivalTime ??= model.ArrivalDate.TimeOfDay;
            var entity = model.Cast();

            await ValidateAppointment(entity);

            await _context.Appointments.AddAsync(entity, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);
        }
コード例 #6
0
        public async Task <ActionResult> ScheduleAppointment(CreateScheduleModel request)
        {
            try
            {
                await _appointmentSchedulerService.ScheduleAppointment(request);

                return(Ok());
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.InnerException?.Message ?? exception.Message));
            }
        }
コード例 #7
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)));
        }
コード例 #8
0
        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());
        }
コード例 #9
0
ファイル: ScheduleService.cs プロジェクト: silver-xu/todo-api
        public async Task CreateSchedule(int userId, CreateScheduleModel scheduleModel)
        {
            var schedule = ScheduleMapper.MapFromCreateScheduleModel(userId, scheduleModel);

            await _scheduleRepository.AddSchedule(schedule);
        }
コード例 #10
0
ファイル: ScheduleService.cs プロジェクト: war-man/SmartKiosk
 public ValidationResult ValidateCreateSchedule(ClaimsPrincipal principal,
                                                CreateScheduleModel model)
 {
     return(ValidationResult.Pass());
 }