Beispiel #1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
 public ActionResult Edit(Persoon persoon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(persoon).State       = EntityState.Modified;
         db.Entry(persoon.Adres).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AdresId = new SelectList(db.adressen, "Id", "Straat", persoon.AdresId);
     return(View(persoon));
 }
        public IHttpActionResult PutCUSTOMER_COMPLAINTS(int id, CUSTOMER_COMPLAINTS cUSTOMER_COMPLAINTS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cUSTOMER_COMPLAINTS.COMPLAINT_ID)
            {
                return(BadRequest());
            }

            db.Entry(cUSTOMER_COMPLAINTS).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CUSTOMER_COMPLAINTSExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #4
0
        public IHttpActionResult PutLOG(long id, LOG lOG)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != lOG.LOG_ID)
            {
                return(BadRequest());
            }

            db.Entry(lOG).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LOGExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutCV_TABLE(long id, CV_USER cV_TABLE)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cV_TABLE.ID)
            {
                return(BadRequest());
            }

            db.Entry(cV_TABLE).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CV_TABLEExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #6
0
        public IHttpActionResult PutATTACHMENT(long id, CV_ITEM_LINK aTTACHMENT)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != aTTACHMENT.ID)
            {
                return(BadRequest());
            }

            db.Entry(aTTACHMENT).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ATTACHMENTExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private void DeleteItem()
 {
     using (var context = new MyEntities())
     {
         context.Entry(_selectedEquipment.ToModel()).State = EntityState.Deleted;
         context.SaveChanges();
     }
     Equipment.Remove(_selectedEquipment);
 }
Beispiel #8
0
 public ActionResult Edit([Bind(Include = "Id,Name,Location")] RESTAURANT rESTAURANT)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rESTAURANT).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(rESTAURANT));
 }
 private void saveCommand()
 {
     if (Regex.IsMatch(_selectedEquipment.EquipmentName, @"^^(?! )[A-Za-z\s]+$"))
     {
         using (var context = new MyEntities())
         {
             context.Entry(_selectedEquipment.ToModel()).State = EntityState.Modified;
             context.SaveChanges();
         }
         _listViewModel.CloseEditItem();
     }
 }
Beispiel #10
0
 public ActionResult Edit([Bind(Include = "Id,RestaurantId,UserId,Name,Quality,Taste,Price,Service,Comment")] DISHES_REVIEWS dISHES_REVIEWS)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dISHES_REVIEWS).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RestaurantId = new SelectList(db.RESTAURANTS, "Id", "Name", dISHES_REVIEWS.RestaurantId);
     ViewBag.UserId       = new SelectList(db.USERS, "Id", "UserName", dISHES_REVIEWS.UserId);
     return(View(dISHES_REVIEWS));
 }
Beispiel #11
0
 private void DeleteNinja()
 {
     using (var context = new MyEntities())
     {
         if (_ninjaInventoryWindow != null)
         {
             _ninjaInventoryWindow.Close();
         }
         ServiceLocator.Current.GetInstance <NinjaInventoryViewModel>().CloseShop();
         context.Entry(SelectedNinja.ToModel()).State = EntityState.Deleted;
         context.SaveChanges();
     }
     Ninjas.Remove(SelectedNinja);
 }
        public IHttpActionResult UpdateCriteria(long id, CRITERIA cRITERIA)
        {
            if (HttpContext.Current.Request.Cookies.AllKeys.Contains("sid"))
            {
                try {
                    response = identity.Auth(HttpContext.Current.Request.Cookies.Get("sid").Value);
                }
                catch {
                    return(BadRequest("Invalid token. Login in again!"));
                }
                if (!response.Roles.Contains("ADMIN"))
                {
                    return(BadRequest("You are not authorized for this action"));
                }
            }
            else
            {
                return(BadRequest("You are not logged in. Please login and try again."));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cRITERIA.ID_CRITERIA)
            {
                return(BadRequest("id doesn't match"));
            }
            cRITERIA.DATE_MODIFIED   = DateTime.Now;
            db.Entry(cRITERIA).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CRITERIAExists(id))
                {
                    return(NotFound());
                }
            }

            return(Ok(cRITERIA));
        }
Beispiel #13
0
 public virtual void Update(T entity)
 {
     dbset.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
 }
Beispiel #14
0
        public IHttpActionResult UpdateStatus(long cv_item_id, int status_id)
        {
            if (HttpContext.Current.Request.Cookies.AllKeys.Contains("sid"))
            {
                try
                {
                    response = identity.Auth(HttpContext.Current.Request.Cookies.Get("sid").Value);
                }
                catch
                {
                    return(BadRequest("Invalid token. Login in again!"));
                }
                if (!(response.Roles.Contains("ADMIN") || response.Roles.Contains("STUDENTSKA")))
                {
                    return(BadRequest("You are not authorized for this action"));
                }
            }
            else
            {
                return(BadRequest("You are not logged in. Please login and try again."));
            }



            try
            {
                var status = db.CV_ITEM_STATUS.Where(a => a.ID == status_id).Single();
                var result = db.CV_ITEM.Where(a => a.ID_ITEM == cv_item_id).Single();
                result.STATUS_ID = status_id;

                if (status.STATUS == "confirmed" || status.STATUS == "rejected" || status_id == 3)
                {
                    string statuschange = "";
                    if (status.STATUS == "confirmed")
                    {
                        statuschange = "CONFIRMED";
                    }
                    else if (status.STATUS == "rejected")
                    {
                        statuschange = "REJECTED";
                    }
                    else if (status_id == 3)
                    {
                        statuschange = "RESTORED";
                    }
                    var log = new LOG();
                    log.EVENT_CREATED = DateTime.Now;
                    log.EVENT_TYPE    = statuschange;
                    log.DESCRIPTION   = cv_item_id.ToString();
                    log.USER_ID       = response.UserId;
                    db.LOG.Add(log);
                    db.SaveChanges();
                }

                //saving to database
                db.Entry(result).State = EntityState.Modified;
                db.SaveChanges();
                return(Ok());
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }