Beispiel #1
0
        public Guid Upsert(AppointmentTypeProxy proxy)
        {
            try
            {
                var             repo = this.RepoFactory.Get <AppointmentTypeRepository>();
                AppointmentType appointmentType;

                if (proxy.Id.HasValue)
                {
                    appointmentType = repo.GetById(proxy.Id);
                }
                else
                {
                    appointmentType    = new AppointmentType();
                    appointmentType.Id = Guid.NewGuid();
                    repo.Add(appointmentType);
                }

                appointmentType.Name  = proxy.Name;
                appointmentType.Value = proxy.Value;

                repo.SaveChanges();

                return(appointmentType.Id);
            }
            catch (Exception)
            {
                throw new UserException("Грешка при записването на видът ангажимент");;
            }
        }
        public JsonResult Upsert(AppointmentTypeProxy proxy)
        {
            var response = new ResponseModel();

            try
            {
                response.Data = Service.Upsert(proxy);
            }
            catch (Exception ex)
            {
                response.SetException(ex);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }