// PUT api/rtpplancycle/5 public void Put(PlanCycle cycle) { try { TripsRepository.UpdateRtpPlanCycle(cycle); } catch (Exception ex) { Logger.WarnException("Could not update RTP Plan Cycle", ex); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message }); } }
// POST api/rtpplancycle public int Post(PostData data) { var cycle = new PlanCycle() { Name = data.name, Description = data.description }; try { return TripsRepository.CreateRtpPlanCycle(cycle, data.rtpYearId); } catch (Exception ex) { Logger.WarnException("Could not create RTP Plan Cycle", ex); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message }); } }
public void CrudRtpPlanCycleTest() { TripsRepository target = new TripsRepository(); var cycle = new DRCOG.Domain.ViewModels.RTP.PlanCycle() { Name = "Testicle", Description = "A Test Cycle" }; string rtpYear = "2035-S"; int yid = target.GetRtpPlanYearId(rtpYear); int cid = target.CreateRtpPlanCycle(cycle, yid); Assert.IsTrue(cid > 0, "Create RTP Plan Cycle makes an ID > 0"); var editCycle = target.GetRtpPlanCycle(cid); Assert.AreEqual(editCycle.Status, "New", "Create RTP Plan Cycle sets status to New"); Assert.IsNotNull(editCycle, "Get RTP Plan Cycle retrieves a PlanCycle"); editCycle.Name = "TestEdit"; editCycle.Description = "Edited Test Cycle"; target.UpdateRtpPlanCycle(editCycle); var actual = target.GetRtpPlanCycle(editCycle.Id); Assert.AreEqual(editCycle.Name, actual.Name, "UpdateRtpPlanCycle updates Name"); Assert.AreEqual(editCycle.Description, actual.Description, "UpdateRtpPlanCycle updates Description"); target.DeleteRtpPlanCycle(cid); }