コード例 #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("Грешка при записването на видът ангажимент");;
            }
        }
コード例 #2
0
        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));
        }