コード例 #1
0
 //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;
     }
 }
コード例 #2
0
 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"
         });
     }
 }
コード例 #3
0
        //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;
            }
        }
コード例 #4
0
 public static Plan PlanToDomain(PlanDTO PlanDTO)
 {
     if (PlanDTO == null) return null;
      Mapper.CreateMap<PlanDTO, Plan>();
      Plan Plan = Mapper.Map<Plan>(PlanDTO);
      return Plan;
 }