public Schedule CreateSchedule(CreateScheduleModel model) { var entity = model.ToDest(); PrepareCreate(entity); return(context.Schedule.Add(entity).Entity); }
public ScheduleModel Create(CreateScheduleModel model) { try { if (model.Invalid) { return(default);
public async Task <IActionResult> Create([FromBody] CreateScheduleModel createScheduleModel) { var userId = int.Parse(HttpContext.User.Identity.Name); await _scheduleService.CreateSchedule(userId, createScheduleModel); return(NoContent()); }
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); }
public async Task <ActionResult> ScheduleAppointment(CreateScheduleModel request) { try { await _appointmentSchedulerService.ScheduleAppointment(request); return(Ok()); } catch (Exception exception) { return(BadRequest(exception.InnerException?.Message ?? exception.Message)); } }
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))); }
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 CreateSchedule(int userId, CreateScheduleModel scheduleModel) { var schedule = ScheduleMapper.MapFromCreateScheduleModel(userId, scheduleModel); await _scheduleRepository.AddSchedule(schedule); }
public ValidationResult ValidateCreateSchedule(ClaimsPrincipal principal, CreateScheduleModel model) { return(ValidationResult.Pass()); }