Ejemplo n.º 1
0
 public ActionResult EditPollPost(Poll modifiedPoll)
 {
     List<Category> pollCategories = new List<Category>();
     pollCategories = categoryRepository.GetActive();
     ViewBag.Categories = pollCategories;
     int result = this.pollRepository.Save(modifiedPoll);
     if (result > 0)
     {
         ViewBag.Message = "The record is successfully edited.";
     }
     else
     {
         ViewBag.Message = "An error occured and the record failed to update. Please check the information entered or try again later.";
     }
     return View(modifiedPoll);
 }
Ejemplo n.º 2
0
        public HttpResponseMessage Post(PollModel pollModel)
        {
            if (ModelState.IsValid)
            {
                Poll o = new Poll();
                Category c = this.categoryRepository.GetById(pollModel.CategoryId);

                o.StartDate = pollModel.StartDate;
                o.EndDate = pollModel.EndDate;
                o.CategoryId = pollModel.CategoryId;
                o.Category = c;
                o.Frequency = (Frequency)pollModel.FrequencyId;
                o.VoteCountPerFrequency = pollModel.VoteCountPerFrequency;
                pollRepository.Save(o);

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, pollModel);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = pollModel.PollId }));
                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
Ejemplo n.º 3
0
        public ActionResult AddPollPost(Poll myPoll)
        {
            List<Category> pollCategories = new List<Category>();
            pollCategories = categoryRepository.GetActive();
            ViewBag.Categories = pollCategories;

            int result = this.pollRepository.Save(myPoll);
            if (result > 0)
            {
                ViewBag.Message = "The poll was successfully saved.";
            }
            return View(myPoll);
        }