Esempio n. 1
0
        // PUT api/plans/5
        public void Put(int id, NewPlan planData)
        {
            Plan plan = _db.Plans.GetById(id);
            if (plan == null)
                throw new HttpResponseException(HttpStatusCode.NotFound);

            plan.PlanName = planData.PlanName;
            plan.MonthlyCost = planData.MonthlyCost;
            plan.VoiceMinutes = planData.VoiceMinutes;
            plan.DataMegabytes = planData.DataMegabytes;

            _db.Commit();
        }
Esempio n. 2
0
        // POST api/plans
        public int Post(NewPlan newPlan)
        {
            Plan plan = new Plan();

            plan.PlanName = newPlan.PlanName;
            plan.MonthlyCost = newPlan.MonthlyCost;
            plan.VoiceMinutes = newPlan.VoiceMinutes;
            plan.DataMegabytes = newPlan.DataMegabytes;

            _db.Plans.Add(plan);
            _db.Commit();

            return plan.PlanId;
        }