Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "Id_Materiales,Mat_Nombre,Mat_Descripcion,Mat_Estado")] Materiales materiales)
 {
     if (ModelState.IsValid)
     {
         db.Entry(materiales).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(materiales));
 }
 public ActionResult Edit([Bind(Include = "DrawingTypeId,Name")] DrawingsType drawingsType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(drawingsType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(drawingsType));
 }
 public ActionResult Edit([Bind(Include = "CategoriaID,Nome,Ativo")] Categoria categoria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoria));
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "id,UserName,Password")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "id,Name,Phone,Adress,City,State")] Carrier carrier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carrier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(carrier));
 }
Ejemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "Id_Contacto,Cont_Nombre,Cont_Estado")] Contacto contacto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contacto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(contacto));
 }
Ejemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "id,aName,DOB,city")] Artist artist)
 {
     if (ModelState.IsValid)
     {
         db.Entry(artist).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(artist));
 }
Ejemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "TaskId,TaskName")] AssignTask assignTask)
 {
     if (ModelState.IsValid)
     {
         db.Entry(assignTask).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(assignTask));
 }
Ejemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "Id,SchoolName,Address,Founder")] School school)
 {
     if (ModelState.IsValid)
     {
         db.Entry(school).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(school));
 }
 public ActionResult ArtistUpdate([Bind(Include = "ArtistID,ArtistName,ArtistDOB,ArtistCity")] Artist artist)
 {
     if (ModelState.IsValid)
     {
         db.Entry(artist).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Artists"));
     }
     return(View(artist));
 }
Ejemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "TagId,TagName")] Tag tag)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tag).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tag));
 }
Ejemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "id,iName,descript,sellerID")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.sellerID = new SelectList(db.Sellers, "id", "sName", item.sellerID);
     return(View(item));
 }
Ejemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "busId,busNo,busCapacity,busStatus,companyId")] Bus bus)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bus).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.companyId = new SelectList(db.Company, "companyId", "companName", bus.companyId);
     return(View(bus));
 }
Ejemplo n.º 14
0
 public void Set(SysAccount ob)
 {
     if (ob.AccountId <= 0)
     {
         db.SysAccount.Add(ob);
     }
     else
     {
         db.Entry(ob).State = EntityState.Modified;
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Закрыть форму
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnConfirm_Click(object sender, EventArgs e)
 {
     using (var db = new dbContext())
     {
         //При закрытии формы мы сохраняем наши параметры
         foreach (var item in modelVisible)
         {
             db.Entry(item).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
         //При закрытии формы мы сохраняем наши параметры
         foreach (var item in modelUnVisible)
         {
             db.Entry(item).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Ejemplo n.º 16
0
        public async Task <IActionResult> UpdateUsuario(int id, Usuario usuario)
        {
            if (id != usuario.IdUsuario)
            {
                return(BadRequest());
            }

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

            return(NoContent());
        }
Ejemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "id,id_Carrier,id_User,Rating")] CarrierRating carrierRating)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carrierRating).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_Carrier = new SelectList(db.Carrier, "id", "Name", carrierRating.id_Carrier);
     ViewBag.id_User    = new SelectList(db.User, "id", "UserName", carrierRating.id_User);
     return(View(carrierRating));
 }
Ejemplo n.º 18
0
        public async Task <IActionResult> PutUser(Guid id, User item)
        {
            if (id.ToString() != item.UserId.ToString())
            {
                return(BadRequest());
            }

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

            return(NoContent());
        }
Ejemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "id,itemID,buyerID,price,timeOffered")] Bid bid)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bid).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.buyerID = new SelectList(db.Buyers, "id", "bName", bid.buyerID);
     ViewBag.itemID  = new SelectList(db.Items, "id", "iName", bid.itemID);
     return(View(bid));
 }
Ejemplo n.º 20
0
        public async Task <IActionResult> PutProduct(Guid id, Product item)
        {
            if (id != item.ProductId)
            {
                return(BadRequest());
            }

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

            return(NoContent());
        }
Ejemplo n.º 21
0
        public async Task <JsonResult> UpDatePost(PostModel postModel)
        {
            try
            {
                var post = new MPosts();
                post.PostBody  = postModel.PostBody;
                post.UserEmail = postModel.UserEmail;
                post.Id        = postModel.Id;
                post.Title     = postModel.Title;

                var existingPost = db.MPosts.Find(post.Id);
                if (existingPost == null)
                {
                    return(Json(new
                    {
                        res = "err",
                        msg = $"Post with id={post.Id} does not exist"
                    }));
                }
                //update the fields that can change
                existingPost.Title           = post.Title;
                existingPost.PostBody        = post.PostBody;
                db.Entry(existingPost).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                await db.SaveChangesAsync();

                return(Json(new
                {
                    res = "ok",
                    data = "Post updated"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    res = "err",
                    msg = ex.Message
                }));
            }
        }
Ejemplo n.º 22
0
 public ActionResult Edit([Bind(Include = "PROPERTYID,SIZE,RENT,SELL,DESCRIPTION,ADDRESS,IsActive,PROPERTYTYPEID,REGIONID,OWNERID")] PROPERTIES pROPERTIES)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pROPERTIES).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OWNERID        = new SelectList(db.OWNERS, "OWNERID", "FNAME", pROPERTIES.OWNERID);
     ViewBag.PROPERTYTYPEID = new SelectList(db.PROPERTYTYPES, "ID", "TYPE", pROPERTIES.PROPERTYTYPEID);
     ViewBag.REGIONID       = new SelectList(db.REGIONS, "REGIONID", "REGIONNAME", pROPERTIES.REGIONID);
     return(View(pROPERTIES));
 }
Ejemplo n.º 23
0
        private void button7_Click(object sender, EventArgs e)
        {
            Produto p = new Produto()
            {
                Id        = 2,
                Nome      = "Teste 22",
                LojaId    = 2,
                Descricao = "testes"
            };

            dbContext.Entry(p).State = EntityState.Modified;
            dbContext.SaveChanges();
        }
Ejemplo n.º 24
0
 public ActionResult Edit([Bind(Include = "BlogId,TagId,BlogTitle,BlogDescription,BlogExampleUrl,Status")] Blog blog)
 {
     if (ModelState.IsValid)
     {
         blog.ModifiedDate    = DateTime.Now;
         blog.CreatedDate     = DateTime.Now;
         db.Entry(blog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TagId = new SelectList(db.Tags, "TagId", "TagName", blog.TagId);
     return(View(blog));
 }
Ejemplo n.º 25
0
        public virtual T Update(T entity, bool save = true)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity not found");
            }

            _dbContext.Entry <T>(entity).State = System.Data.Entity.EntityState.Modified;
            if (save)
            {
                Save();
            }
            return(entity);
        }
Ejemplo n.º 26
0
        public ActionResult Details(int id)
        {
            dbContext db  = new dbContext();
            var       ord = db.OrderSet.Find(id);

            ord.Status          = 1;
            db.Entry(ord).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            ViewBag.FIO       = db.OrderSet.Find(id).FIO;
            ViewBag.Price     = db.OrderSet.Find(id).Price;
            ViewBag.Telephone = db.OrderSet.Find(id).Telephone;
            var a = (from u in db.ItemOrderSet where u.OrderId == id select u).ToList();

            return(PartialView(a));
        }
Ejemplo n.º 27
0
        public bool placeOrderByStockId(int id)
        {
            bool success = false;

            using (var context = new dbContext())
            {
                stockModel Stock = context.Stocks.SingleOrDefault(r => r.id == id);
                driver.Navigate().GoToUrl(Stock.url);

                //Thread.Sleep(10000);
                //string css = "div.sort-list:first-child .view-all";
                //IWebElement ViewAll = driver.FindElement(By.CssSelector(css));
                //ViewAll.Click();

                //css = ".products li:nth-child(" + Stock.countId + ") div";
                //IWebElement product = driver.FindElement(By.CssSelector(css));
                //product.Click();

                string      css   = "ul li:first-child div";
                IWebElement color = driver.FindElement(By.CssSelector(css));
                color.Click();
                ((IJavaScriptExecutor)driver).ExecuteScript("$('.chosen :nth(1)').attr('selected', true)");
                ((IJavaScriptExecutor)driver).ExecuteScript(" $('.add-button button').click()");
                Thread.Sleep(3000);
                string returnMessage = (string)((IJavaScriptExecutor)driver).ExecuteScript("return  $('.errors div:nth(2)').text()");
                if (returnMessage == "We're sorry, the selected item does not have 1 item in stock. Please try again.")
                {
                    success = false;

                    using (var contexts = new dbContext())
                    {
                        Stock.inStock = false;
                        contexts.Stocks.Attach(Stock);
                        var entry = contexts.Entry(Stock);
                        entry.Property(e => e.inStock).IsModified = true;
                        // other changed properties
                        contexts.SaveChanges();
                    }
                }
                if (returnMessage != "We're sorry, the selected item does not have 1 item in stock. Please try again.")
                {
                    success = true;
                }
            }

            return(success);
        }
Ejemplo n.º 28
0
        public async Task <AccountResponse> Authenticate(string email, string password)
        {
            var user = await Task.Run(() => _context.Account.FirstOrDefault(x => x.email_address == email));

            _context.Entry(user).State = EntityState.Detached;

            if (user == null)
            {
                return(null);
            }

            if (!BCrypt.Net.BCrypt.Verify(password, user.password))
            {
                return(null);
            }

            return(_mapper.Map <AccountResponse>(user.WithoutPassword()));
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> EditRecord(MRabbitsTreatmentRecords rabbit)
        {
            ViewBag.title = "Edit Record";
            try
            {
                db.Entry(rabbit).State = EntityState.Modified;
                await db.SaveChangesAsync();

                TempData["msg"]  = "Saved";
                TempData["type"] = "success";
            }
            catch (Exception ex)
            {
                TempData["msg"]  = ex.Message;
                TempData["type"] = "error";
            }
            return(RedirectToAction("EditRecord", "RabbitsTreatment", new { id = rabbit.Id }));
        }
 public void Edit(Product product, string name, string price, string contents, Category category)
 {
     if (name != "")
     {
         product.Name = name;
     }
     if (price != "")
     {
         product.Price = price;
     }
     if (contents != "")
     {
         product.Contents = contents;
     }
     product.CategoryId             = category.Id;
     dbContext.Entry(product).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     dbContext.SaveChanges();
 }