public JsonResult Save(AppointmentInfoProxy proxy) { var response = new ResponseModel(); try { Service.Save(proxy); } catch (Exception ex) { response.SetException(ex); } return(Json(response, JsonRequestBehavior.AllowGet)); }
public void Save(AppointmentInfoProxy proxy) { if (proxy.EmployeeId == Guid.Empty) { throw new UserException("Изберете служител"); } if (proxy.PartnerId == Guid.Empty) { throw new UserException("Изберете партньор"); } if (proxy.TypeId == Guid.Empty) { throw new UserException("Изберете тип"); } if (proxy.Date == DateTime.MinValue) { throw new UserException("Изберете дата"); } if (proxy.Count <= 0) { throw new UserException("Невалиден брой"); } try { var repo = this.RepoFactory.Get <AppointmentInfoRepository>(); var appointmentInfo = new AppointmentInfo { Id = Guid.NewGuid(), EmployeeId = proxy.EmployeeId, PartnerId = proxy.PartnerId, TypeId = proxy.TypeId, Date = proxy.Date, Count = proxy.Count }; repo.Add(appointmentInfo); repo.SaveChanges(); } catch (Exception) { throw new UserException("Грешка при записването на ангажиментът");; } }