public AppointmentIntervalViewModel CreateAppointmentIntervalViewModel(Trust trust)
        {
            var model = new AppointmentIntervalViewModel {
                IsModelEditable = false
            };

            if (trust == null)
            {
                return(model);
            }

            model = Mapper.Map <Trust, AppointmentIntervalViewModel>(trust);
            model.IsModelEditable = true;
            model.TrustId         = trust.Id;

            return(model);
        }
        public object SaveAppointmentInterval(AppointmentIntervalViewModel model, string user)
        {
            var trust = trustService.GetTrustById(model.TrustId);

            if (trust == null)
            {
                return new { IsSuccess = false, Message = "Appointment intervals save failed" }
            }
            ;

            if (repository.GetContext().PatientAppointments.Any(p => !p.IsArchived))
            {
                return(new { IsSuccess = false, Message = "One or more appointments have been scheduled. Intervals can be updated only when there is no appointments scheduled in the system." });
            }

            trust = Mapper.Map(model, trust);

            trust.SetUpdateDetails(user);
            repository.SaveExisting(trust);

            return(new { IsSuccess = true, Message = "Appointment intervals saved successfully" });
        }
    }
 public IActionResult SaveAppointmentIntarval(AppointmentIntervalViewModel model)
 {
     return(Json(SchServ.SaveAppointmentInterval(model, CurrentUserName)));
 }