Пример #1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Admin, "post", Route = "updateschedule")] UpdateScheduleModel updateScheduleModel,
            [DurableClient] IDurableOrchestrationClient starter,
            ILogger log)
        {
            log.LogUpdateSchedule(updateScheduleModel, nameof(UpdateScheduleTrigger));

            if (updateScheduleModel.UpdateAllTeams)
            {
                var connections = await _scheduleConnectorService.ListConnectionsAsync().ConfigureAwait(false);

                var teamIds = new List <string>();
                foreach (var connection in connections)
                {
                    teamIds.Add(connection.TeamId);
                }
                updateScheduleModel.TeamIds = string.Join(",", teamIds);
            }

            if (await starter.TryStartSingletonAsync(nameof(UpdateScheduleOrchestrator), UpdateScheduleOrchestrator.InstanceId, updateScheduleModel).ConfigureAwait(false))
            {
                return(new OkResult());
            }
            else
            {
                return(new ConflictResult());
            }
        }
Пример #2
0
        public async Task <ActionResult> UpdateAppointment(UpdateScheduleModel request)
        {
            try
            {
                await _appointmentSchedulerService.UpdateAppointment(request);

                return(Ok());
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.InnerException?.Message ?? exception.Message));
            }
        }
Пример #3
0
        public async Task UpdateSchedule(int userId, int scheduleId, UpdateScheduleModel scheduleModel)
        {
            var schedule = await _scheduleRepository.GetSchedule(scheduleId);

            if (schedule == null || schedule.UserId != userId)
            {
                throw new NotFoundException();
            }

            var updatedSchedule = ScheduleMapper.MapFromUpdateScheduleModel(userId, scheduleId, scheduleModel);

            await _scheduleRepository.UpdateSchedule(updatedSchedule);
        }
Пример #4
0
        public async Task <IActionResult> Update(int scheduleId, [FromBody] UpdateScheduleModel updateScheduleModel)
        {
            var userId = int.Parse(HttpContext.User.Identity.Name);

            try
            {
                await _scheduleService.UpdateSchedule(userId, scheduleId, updateScheduleModel);
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }

            return(NoContent());
        }
        public async Task UpdateAppointment(UpdateScheduleModel model, CancellationToken cancellationToken = default)
        {
            model.ArrivalTime ??= model.ArrivalDate.TimeOfDay;
            var entity = await _context.Appointments.FindAsync(model.UserId, model.BranchId, model.ServiceId);

            if (entity == null)
            {
                throw new NotFoundException(nameof(Appointment), new { model.UserId, model.BranchId, model.ServiceId });
            }

            var mappedEntity = model.Map(entity);

            await ValidateAppointment(entity);

            _context.Appointments.Update(mappedEntity);

            await _context.SaveChangesAsync(cancellationToken);
        }
Пример #6
0
        public IActionResult Update(int id, UpdateScheduleModel model)
        {
            var entity = _service.Schedules.Id(id).FirstOrDefault();

            if (entity == null)
            {
                return(NotFound(new AppResultBuilder().NotFound()));
            }
            var validationResult = _service.ValidateUpdateSchedule(User, entity, model);

            if (!validationResult.Valid)
            {
                return(BadRequest(validationResult.Result));
            }
            _service.UpdateSchedule(entity, model);
            context.SaveChanges();
            return(NoContent());
        }
Пример #7
0
        public IActionResult Alter(long CustomerId, long DoctorId, string Date, long id)
        {
            UpdateScheduleModel update = new UpdateScheduleModel(id
                                                                 , Convert.ToDateTime(Date)
                                                                 , _customerService.GetCustomerById(CustomerId)
                                                                 , _doctorService.GetDoctorById(DoctorId));

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

                return(View("New"));
            }

            ViewData["ScheduleView"] = _mapper.Map <ScheduleView>(_scheduleService.Update(update));
            return(View());
        }
Пример #8
0
 public static Schedule MapFromUpdateScheduleModel(int userId, int scheduleId, UpdateScheduleModel model)
 {
     return(new Schedule
     {
         ScheduleId = scheduleId,
         Description = model.Description,
         UserId = userId,
         ScheduleDate = model.ScheduleDate
     });
 }
Пример #9
0
 public ValidationResult ValidateUpdateSchedule(ClaimsPrincipal principal,
                                                Schedule entity, UpdateScheduleModel model)
 {
     return(ValidationResult.Pass());
 }
Пример #10
0
 public void UpdateSchedule(Schedule entity, UpdateScheduleModel model)
 {
     model.CopyTo(entity);
 }
 public static void LogUpdateSchedule(this ILogger log, UpdateScheduleModel updateScheduleModel, string operationName)
 {
     log.LogInformation(EventIds.Schedule, "UpdateSchedule: TeamIds={teamIds}, UpdateAllTeams={updateAllTeams}, OperationName={operationName}", updateScheduleModel.TeamIds, updateScheduleModel.UpdateAllTeams, operationName);
 }