public ActionResult Edit(Recipe recipe, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string ImageName    = System.IO.Path.GetFileName(file.FileName);
                    string physicalPath = Server.MapPath("~/images/" + ImageName);

                    file.SaveAs(physicalPath);

                    db.Entry(recipe).State = EntityState.Modified;
                    //model.name = Request.Form["name"];
                    //model.category = Request.Form["category"];
                    //model.content = Request.Form["content"];
                    //model.type = Request.Form["type"];
                    recipe.image = ImageName;
                    db.SaveChanges();
                    return(RedirectToAction("edit", "recipes"));
                }
                else
                {
                    db.Entry(recipe).State = EntityState.Modified;
                    //model.name = Request.Form["name"];
                    //model.category = Request.Form["category"];
                    //model.content = Request.Form["content"];
                    //model.type = Request.Form["type"];

                    db.SaveChanges();
                    return(RedirectToAction("recipe", "users"));
                }
            }
            ViewBag.manager = new SelectList(db.user, "id", "name", recipe.manager);
            return(View(recipe));
        }
Esempio n. 2
0
        public void Update(TEntityDTO entity)
        {
            var mappedEntity = Mapper.Map <TEntity>(entity);

            Db.Entry(mappedEntity).State = EntityState.Modified;
            Db.SaveChanges();
        }
Esempio n. 3
0
        public async Task <IActionResult> PutAccount(int id, Account account)
        {
            if (id != account.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 4
0
 public ActionResult contestEdit([Bind(Include = "id,name,content,createAt,startDate,endDate")] Contest editcontest)
 {
     //Check contest name exist
     if (db.contest.Any(x => x.name == editcontest.name && x.id != editcontest.id))
     {
         ModelState.AddModelError("name", "Contest name already exist");
         return(View(editcontest));
     }
     //Check start date
     if (editcontest.startDate < editcontest.createAt)
     {
         ModelState.AddModelError("startDate", "Start date cannot be less than create date");
         return(View(editcontest));
     }
     //Check end date
     if (editcontest.endDate <= editcontest.startDate)
     {
         ModelState.AddModelError("endDate", "End date cannot be equal or less than start date");
         return(View(editcontest));
     }
     if (ModelState.IsValid)
     {
         db.Entry(editcontest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("contestIndex", "admin"));
     }
     return(View(editcontest));
 }
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 6
0
        public string Edit_User(JObject jsonResult)
        {
            var modify = JsonConvert.DeserializeObject <User>(jsonResult.ToString());

            _db.Entry(modify).State = EntityState.Modified;
            _db.SaveChanges();
            return("کاربر تغییر یافت");
        }
        public string Edit_Product(JObject jsonResult)
        {
            var modify = JsonConvert.DeserializeObject <Product>(jsonResult.ToString());

            _db.Entry(modify).State = EntityState.Modified;
            _db.SaveChanges();
            return("محصول مورد نظر تغییر یافت");
        }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "usuarioId,nombre,password,apellido")] Usuario usuario)
 {
     if (ModelState.IsValid)
     {
         db.Entry(usuario).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(usuario));
 }
Esempio n. 9
0
 public ActionResult Edit([Bind(Include = "id,nome,dt_nascimento,telefone,email,cidade")] Cliente cliente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cliente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cliente));
 }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "id,name,Education,age,technical_exp,Last_co_worked")] EmpMaster empMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(empMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(empMaster));
 }
Esempio n. 11
0
 public ActionResult Edit([Bind(Include = "Nome,Sexo,Endereco,DataN,CarteraT,Fonef,Fonec,Email")] operario operario)
 {
     if (ModelState.IsValid)
     {
         db.Entry(operario).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(operario));
 }
Esempio n. 12
0
 public ActionResult Edit(TRACK track)
 {
     if (ModelState.IsValid)
     {
         db.Entry(track).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(track));
 }
Esempio n. 13
0
 public ActionResult Edit([Bind(Include = "id,loginname,loginpwd,pid,mobileid,roleid,status,md5pass")] UserLogin userLogin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userLogin).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userLogin));
 }
Esempio n. 14
0
 public ActionResult Edit([Bind(Include = "feedBackId,feedBack")] FeedBack feedBack)
 {
     if (ModelState.IsValid)
     {
         db.Entry(feedBack).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(feedBack));
 }
Esempio n. 15
0
 public ActionResult Edit([Bind(Include = "managerId,FirstName,LastName,Email,Phone,Department")] Manager manager)
 {
     if (ModelState.IsValid)
     {
         db.Entry(manager).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(manager));
 }
Esempio n. 16
0
 //[ValidateAntiForgeryToken]
 public ActionResult Edit([Bind(Include = "idJogo,nomeJogo,precoJogo,generoJogo,dataCompra")] jogo jogo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(jogo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(jogo));
 }
        public async Task <IActionResult> Putuser(long id, user item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
        public ActionResult Sua(BOOKS sach, HttpPostedFileBase Hinhminhhoa)
        {
            var a = sach;

            if (Hinhminhhoa != null && Hinhminhhoa.ContentLength > 0)
            {
                var TenAnh   = Path.GetFileName(Hinhminhhoa.FileName);
                var DuongDan = Path.Combine(Server.MapPath("~/Content/images/books/"), TenAnh);
                sach.BOOK_URL = TenAnh;
                Hinhminhhoa.SaveAs(DuongDan);
            }
            //sach.Donvitinh = "VND";
            //sach.Ngaycapnhat = DateTime.Now;
            var sachcu = db.BOOKS.Find(sach.ID);

            db.Entry(sachcu).CurrentValues.SetValues(sach);
            db.SaveChanges();
            return(RedirectToAction("TatCaSach"));
        }
Esempio n. 19
0
        public ActionResult Edit(User nuser, string expired)
        {
            var t = nuser.expireDate;

            if (expired == "10")
            {
                nuser.expireDate = (t != null && t > DateTime.Now) ? t.AddMonths(6) : DateTime.Now.AddMonths(6);
            }
            if (expired == "50")
            {
                nuser.expireDate = (t != null && t > DateTime.Now) ? t.AddMonths(6) : DateTime.Now.AddMonths(12);
            }

            if (ModelState.IsValid)
            {
                db.Entry(nuser).State = EntityState.Modified;

                db.SaveChanges();
                return(View(nuser));
            }
            return(View(nuser));
        }