示例#1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
示例#2
0
 public ActionResult Edit([Bind(Include = "oeNumber,blockNumber,SearchoeNumber")] OriginesOEN originesOEN)
 {
     if (ModelState.IsValid)
     {
         db.Entry(originesOEN).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(originesOEN));
 }
        public async Task <Funcionalidade> Alterar(Funcionalidade funcionalidade)
        {
            funcionalidade.DataAtualizacao = DateTime.UtcNow;

            _db.Entry(funcionalidade).State = EntityState.Modified;

            await _db.SaveChangesAsync();

            return(funcionalidade);
        }
示例#4
0
        public async Task <ActionResult> Edit([Bind(Include = "carId,CC,kwFrom,kwTo,HpFrom,HpTo,AnneeDe,AnneeA,Carrosserie,valves,cylinder,CodeMoteur,TypeCarburant,CarburantProcess,Date_Dev,Date_Dev2")] Details details)
        {
            if (ModelState.IsValid)
            {
                db.Entry(details).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(details));
        }
示例#5
0
        public async Task <Usuario> Alterar(Usuario usuario)
        {
            usuario.DataAtualizacao = DateTime.UtcNow;

            _db.Entry(usuario).State = EntityState.Modified;

            await _db.SaveChangesAsync();

            var retorno = await ObterPeloId(usuario.Id);

            return(retorno);
        }
示例#6
0
        public ActionResult Edit(Articles articlesToEdit)
        {
            var originalArticles = (from m in _db.Article
                                    where m.articleId == articlesToEdit.articleId
                                    select m).First();

            if (!ModelState.IsValid)
            {
                return(View("Index"));
            }
            _db.Entry(originalArticles).CurrentValues.SetValues(articlesToEdit);
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
 public ActionResult Confirm(int?id, bool?value)
 {
     if (User.Identity.IsAuthenticated)
     {
         if (db.Users.Where(m => m.Email == User.Identity.Name && m.RoleId == 2).FirstOrDefault() != null)
         {
             if (id == null || value == null)
             {
                 return(HttpNotFound());
             }
             var publication = db.Publications.Where(m => m.Id == id).FirstOrDefault();
             if (publication != null)
             {
                 if (value == true)
                 {
                     publication.IsApprovedByAdmin = true;
                     publication.IsActive          = true;
                     db.Entry(publication).State   = EntityState.Modified;
                 }
                 else
                 {
                     db.Publications.Remove(publication);
                 }
                 db.SaveChanges();
             }
             return(RedirectToAction("UnconfirmedPublications"));
         }
     }
     return(HttpNotFound());
 }
示例#8
0
        public IHttpActionResult PutBook(int id, Book book)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != book.Id)
            {
                return(BadRequest());
            }

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

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

            return(Ok(book));
        }
示例#9
0
        public async Task <IActionResult> PutQuestions([FromRoute] int id, [FromBody] Questions questions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != questions.QuestionId)
            {
                return(BadRequest());
            }

            _context.Entry(questions).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuestionsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public IHttpActionResult PutLoanMaster(int id, LoanMaster loanMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != loanMaster.LoanID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#11
0
        public async Task <IActionResult> PutFisher(int id, Fisher fisher)
        {
            if (id != fisher.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(fisher).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FisherExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#12
0
        public async Task <IActionResult> PutReject(int id, Reject reject)
        {
            if (id != reject.rejectId)
            {
                return(BadRequest());
            }

            _context.Entry(reject).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RejectExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#13
0
        public async Task <IHttpActionResult> PutBrand(int id, Brand brand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BrandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#14
0
        public async Task <IHttpActionResult> PutUser(string id, User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.UserName)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult Edit(Customer customer)
 {
     if (ModelState.IsValid)
     {
         _context.Entry(customer).State = EntityState.Modified;
         _context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
示例#16
0
 public ActionResult Edit([Bind(Include = "ExpenseItemID,ExpenseItemName")] ExpenseItem expenseItem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(expenseItem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(expenseItem));
 }
示例#17
0
 public ActionResult Edit([Bind(Include = "ID,Title,ReleaseDate,Genre,Price")] Movie movie)
 {
     if (ModelState.IsValid)
     {
         db.Entry(movie).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(movie));
 }
示例#18
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Apprentice apprentice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(apprentice).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(apprentice));
 }
示例#19
0
 public ActionResult Edit([Bind(Include = "ID,CompanyName,Address,PhoneNumber")] Supplier supplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplier));
 }
示例#20
0
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,email")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
示例#21
0
 public ActionResult Edit([Bind(Include = "PersonID,Firstname,Surname,Age,Active,Birthday")] Person person)
 {
     if (ModelState.IsValid)
     {
         db.Entry(person).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(person));
 }
示例#22
0
 public ActionResult Edit([Bind(Include = "Id,login,role,password")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
示例#23
0
 public ActionResult Edit([Bind(Include = "brandNo,brandName,NAVbrandName,BrandConfiance,Note")] Brand brand)
 {
     if (ModelState.IsValid)
     {
         db.Entry(brand).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(brand));
 }
 public ActionResult Edit([Bind(Include = "Id,ItemDesc,CategoryId,Isactive")] ItemName itemName)
 {
     if (ModelState.IsValid)
     {
         db.Entry(itemName).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", itemName.CategoryId);
     return(View(itemName));
 }
        public async Task <ActionResult> Edit([Bind(Include = "PaymentModeID,PaymentMode")] PaymentModeMaster paymentModeMaster)
        {
            if (ModelState.IsValid)
            {
                db.Entry(paymentModeMaster).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(paymentModeMaster));
        }
示例#26
0
 public ActionResult Edit([Bind(Include = "ID,ProductName,ProductType,cost,ImageURL,Description,Amount,SupplierId")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SupplierId = new SelectList(db.Suppliers, "ID", "CompanyName", product.SupplierId);
     return(View(product));
 }
 public ActionResult Edit([Bind(Include = "ExpenseDetailID,ExpenseItemID,ExpenseDetailRemark,ExpenseDate,AddedDate,AddedUser,Deleteddate,DeletedUser,ModifiedDate,ModifiedUser,IsDeleted")] ExpenseDetail expenseDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(expenseDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ExpenseItemID = new SelectList(db.ExpenseItems, "ExpenseItemID", "ExpenseItemName", expenseDetail.ExpenseItemID);
     return(View(expenseDetail));
 }
 public ActionResult Edit([Bind(Include = "LoanID,LoanName,LoanDescription,LoanAmount,FromDate,InterestPercentage,CustomerID,AddedDate,AddedUser")] LoanMaster loanMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(loanMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "CustomerName", loanMaster.CustomerID);
     return(View(loanMaster));
 }
示例#29
0
        public void Save(Pizza pizza)
        {
            using (var db = new WebAppContext())
            {
                var isNew = pizza.Id == 0;

                db.Pizzas.Attach(pizza);
                db.Entry(pizza).State = isNew ? EntityState.Added : EntityState.Modified;
                db.SaveChanges();
            }
        }
        public async Task <ActionResult> Edit([Bind(Include = "StoreID,StoreName,StoreAddress,Street,Phone,StoreTaxId")] Store store)
        {
            if (ModelState.IsValid)
            {
                db.Entry(store).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(store));
        }