Пример #1
0
        public ActionResult Create(Ombudsman ombudsman)
        {
            if (ModelState.IsValid)
            {
                db.Ombudsmen.Add(ombudsman);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(ombudsman);
        }
Пример #2
0
        // POST api/Ombudsman
        public HttpResponseMessage PostOmbudsman(Ombudsman ombudsman)
        {
            if (ModelState.IsValid)
            {
                db.Ombudsmen.AddOrUpdate(ombudsman);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ombudsman);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = ombudsman.OmbudsmanId }));
                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
Пример #3
0
        // PUT api/Ombudsman/5
        public HttpResponseMessage PutOmbudsman(int id, Ombudsman ombudsman)
        {
            if (ModelState.IsValid && id == ombudsman.OmbudsmanId)
            {
                db.Ombudsmen.AddOrUpdate(ombudsman);

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK, ombudsman);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
Пример #4
0
 public ActionResult Edit(Ombudsman ombudsman)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ombudsman).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(ombudsman);
 }