Beispiel #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            PERSOANE persoane = db.PERSOANE.Find(id);

            db.PERSOANE.Remove(persoane);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult makeAnonymous(int id)
        {
            PERSOANE persoane = db.PERSOANE.Find(id);

            persoane.P_NUME    = "-";
            persoane.P_PRENUME = "-";
            db.SaveChanges();
            return(RedirectToAction("Index", "Persons"));
        }
Beispiel #3
0
        //
        // GET: /Persons/Details/5

        public ActionResult Details(int id = 0)
        {
            PERSOANE persoane = db.PERSOANE.Find(id);

            if (persoane == null)
            {
                return(HttpNotFound());
            }
            return(View(persoane));
        }
Beispiel #4
0
 public ActionResult Edit(PERSOANE persoane)
 {
     if (ModelState.IsValid)
     {
         db.Entry(persoane).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.P_ID_TYPE = new SelectList(db.LIBRARIE, "L_ID", "L_NUME", persoane.P_ID_TYPE);
     return(View(persoane));
 }
Beispiel #5
0
        public IHttpActionResult GetPERSOANE(int id)
        {
            PERSOANE pERSOANE = db.PERSOANEs.Find(id);

            if (pERSOANE == null)
            {
                return(NotFound());
            }

            return(Ok(pERSOANE));
        }
Beispiel #6
0
        public ActionResult Create(PERSOANE persoane)
        {
            if (ModelState.IsValid)
            {
                db.PERSOANE.Add(persoane);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.P_ID_TYPE = new SelectList(db.LIBRARIE, "L_ID", "L_NUME", persoane.P_ID_TYPE);
            return(View(persoane));
        }
Beispiel #7
0
        //
        // GET: /Persons/Edit/5

        public ActionResult Edit(int id = 0)
        {
            PERSOANE persoane = db.PERSOANE.Find(id);
            var      idType   = from lib in db.LIBRARIE
                                where lib.L_TIP == "ID"
                                select lib;

            if (persoane == null)
            {
                return(HttpNotFound());
            }
            ViewBag.P_ID_TYPE = new SelectList(idType, "L_ID", "L_NUME", persoane.P_ID_TYPE);
            return(View(persoane));
        }
Beispiel #8
0
        public IHttpActionResult DeletePERSOANE(int id)
        {
            PERSOANE pERSOANE = db.PERSOANEs.Find(id);

            if (pERSOANE == null)
            {
                return(NotFound());
            }

            db.PERSOANEs.Remove(pERSOANE);
            db.SaveChanges();

            return(Ok(pERSOANE));
        }
Beispiel #9
0
        public IHttpActionResult PostPERSOANE(PERSOANE pERSOANE)
        {
            try
            {
                if (pERSOANE.P_ID_TYPE == 0)
                {
                    pERSOANE.P_ID_TYPE = null;
                }
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                db.PERSOANEs.Add(pERSOANE);
                db.SaveChanges();

                //return Ok();
                return(CreatedAtRoute("DefaultApi", new { id = pERSOANE.P_ID }, pERSOANE));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
        public IHttpActionResult PutPERSOANE(int id, PERSOANE pERSOANE)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pERSOANE.P_ID)
            {
                return(BadRequest());
            }
            pERSOANE.LIBRARIE        = null;
            pERSOANE.CONTRACTEs      = null;
            db.Entry(pERSOANE).State = EntityState.Modified;
            if (pERSOANE.P_EMAIL == "")
            {
                pERSOANE.P_EMAIL = null;
            }
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PERSOANEExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }