//Edit plan public static void Edit(PlanDTO planDTO) { try { UnitOfWork uow = new UnitOfWork(); Plan Plan = Transform.PlanToDomain(planDTO); uow.PlanRepo.Update(Plan); uow.SaveChanges(); } catch { throw; } }
public void EditPlan(string accessId, PlanDTO PlanDTO) { try { PlanService.Edit(PlanDTO); } catch (TimeoutException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "Critical Exception" }); } catch (Exception) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "Critical Exception" }); } }
//Create plan public static int Create(PlanDTO PlanDTO) { try { var Plan = new Plan(); using (var uow = new UnitOfWork()) { Plan = Transform.PlanToDomain(PlanDTO); uow.PlanRepo.Insert(Plan); uow.SaveChanges(); return (Plan.Id); } } //catch (LoggedInUserException) //{ // throw new System.TimeoutException(); //} catch (Exception) { throw; } }
public static Plan PlanToDomain(PlanDTO PlanDTO) { if (PlanDTO == null) return null; Mapper.CreateMap<PlanDTO, Plan>(); Plan Plan = Mapper.Map<Plan>(PlanDTO); return Plan; }