public ActionResult DilDuzenle(int id, string ad)  // Post form metodu ile veriler parametreye veriliyor.
        {
            diller dil = model.diller.Find(id);            // id ile select işlemi yapılıyor.

            model.Entry(dil).State = EntityState.Modified; // Entity durumunu Modified olarak tanımladığımızda kod blogunda  bundan sonraki işlemler update komutuyla yapılacaktır.
            dil.ad = ad;                                   // Burada dil değişkeninin ad özelliğine parametreyi atıyoruz.
            model.SaveChanges();                           // Veritabanı üzerinde değişiklikler yapılıyor.
            return(RedirectToAction("Index"));             // ilk açılan Index action'ına yönleniyor.
        }
Ejemplo n.º 2
0
 public ActionResult EditCategory([Bind(Include = "idCategoria,nome")] Categoria categoria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoria));
 }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "id,description,start_time,end_time,fk_skinsInGiveaway,fk_usersInGiveaway")] giveaway giveaway)
 {
     if (ModelState.IsValid)
     {
         db.Entry(giveaway).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.fk_skinsInGiveaway = new SelectList(db.skins_in_giveaway, "id", "id", giveaway.fk_skinsInGiveaway);
     ViewBag.fk_usersInGiveaway = new SelectList(db.users_in_giveaway, "id", "id", giveaway.fk_usersInGiveaway);
     return(View(giveaway));
 }
Ejemplo n.º 4
0
        public static void entryUpdate(object entry, dbEntities dc)
        {
            dc.Entry(entry).State = System.Data.EntityState.Unchanged;
            // 表单中的元素
            List <string> list = System.Web.HttpContext.Current.Request.Form.AllKeys.ToList <string>();

            foreach (var i in entry.GetType().GetProperties())
            {
                if (list.Contains(i.Name))
                {
                    dc.Entry(entry).Property(i.Name).IsModified = true;
                }
            }
        }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "id,username,password,userLevel,first_name,last_name,sex,email,fk_ticket,fk_users_bets,fk_giveaway,fk_evaluation,fk_place")] user user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.fk_evaluation = new SelectList(db.evaluations, "id", "description", user.fk_evaluation);
     ViewBag.fk_giveaway   = new SelectList(db.giveaways, "id", "description", user.fk_giveaway);
     ViewBag.fk_place      = new SelectList(db.places, "id", "id", user.fk_place);
     ViewBag.fk_ticket     = new SelectList(db.tickets, "id", "description", user.fk_ticket);
     ViewBag.fk_users_bets = new SelectList(db.users_bets, "id", "id", user.fk_users_bets);
     return(View(user));
 }
Ejemplo n.º 6
0
        public static void update2(Books entry)
        {
            dbEntities dc = new dbEntities();

            dc.Entry <Books>(entry).State = System.Data.EntityState.Modified;
            dc.SaveChanges();
        }
Ejemplo n.º 7
0
        public ActionResult EditService(ServiceEditModel model)
        {
            if (!ModelState.IsValid)
            {
                TempData["danger"] = "Error";
                return(RedirectToAction("Index", "Service"));
            }

            if (model.Description == null)
            {
                TempData["danger"] = "Error";
                return(RedirectToAction("Index", "Service"));
            }

            var service = _db.Services.FirstOrDefault(x => x.Id.Equals(model.Id));

            if (service == null)
            {
                TempData["danger"] = "Error";
                return(RedirectToAction("Index", "Service"));
            }

            var catId = Guid.Parse(model.FkCategory);

            service.Category         = _db.Categories.FirstOrDefault(x => x.Id.Equals(catId));
            service.FK_Category      = Guid.Parse(model.FkCategory);
            service.Description      = model.Description;
            service.Name             = model.Name;
            service.Price            = model.Price;
            _db.Entry(service).State = EntityState.Modified;
            _db.SaveChanges();

            TempData["success"] = "Service edited";
            return(RedirectToAction("Index", "Service"));
        }
Ejemplo n.º 8
0
        public ActionResult AddStudent(tbl_Student model)
        {
            tbl_Student obj = new tbl_Student();

            if (ModelState.IsValid)
            {
                obj.ID          = model.ID;
                obj.Name        = model.Name;
                obj.Fname       = model.Fname;
                obj.Email       = model.Email;
                obj.Mobile      = model.Mobile;
                obj.Description = model.Description;

                if (model.ID == 0)
                {
                    dbObj.tbl_Student.Add(obj);
                    dbObj.SaveChanges();
                }
                else
                {
                    dbObj.Entry(obj).State = EntityState.Modified;
                    dbObj.SaveChanges();
                }
            }
            ModelState.Clear();

            return(View("Student"));
        }
Ejemplo n.º 9
0
 // 更新方法二
 public static void updateTwo(db.Books entry)
 {
     db.dbEntities dc = new dbEntities();
     // 1. 将entry附加到entry 2. 附加之后,将他的状态改成修改状态
     dc.Entry <db.Books>(entry).State
         = System.Data.EntityState.Modified;
     dc.SaveChanges();
 }
Ejemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "Id,IsAdmin,Email,Location,FirstName,LastName,Password")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
Ejemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "VOppID,OName,ODate,OCenter,OSkills")] Odb odb)
 {
     if (ModelState.IsValid)
     {
         db.Entry(odb).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(odb));
 }
Ejemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "dni,nombre,email,fecha_nacimiento")] Persona persona)
 {
     if (ModelState.IsValid)
     {
         db.Entry(persona).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(persona));
 }
Ejemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "id,isTangible,category,assetType,assetName,assetDescription,assetState,assetLocation,acquisitionValue,warrantyTime,assetLifeTime,deprecation,salvageValue,acquisitionDate,registrationDate,picture")] Asset asset)
 {
     if (ModelState.IsValid)
     {
         db.Entry(asset).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(asset));
 }
Ejemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "Id,Name,Title,Text,Pay,Contact,Adress")] Ads ads)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ads).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ads));
 }
Ejemplo n.º 15
0
 public ActionResult Edit([Bind(Include = "Id,baslik,isim")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Ejemplo n.º 16
0
 public ActionResult Edit([Bind(Include = "id,name,fk_skinsInGiveaway")] skin skin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(skin).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(skin));
 }
Ejemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "id,firstName,middleName,lastName1,lastName2,birthDate,employeeState,startDate,picture")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
Ejemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "Id,Title")] UserTypeSet userTypeSet)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userTypeSet).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userTypeSet));
 }
Ejemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "id,branchName,branchDescription,province,canton,district,branchLocation,branchState")] Branch branch)
 {
     if (ModelState.IsValid)
     {
         db.Entry(branch).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(branch));
 }
Ejemplo n.º 20
0
 public ActionResult Edit([Bind(Include = "id,first_name,last_name,sex,email,rating,age,country,assists,headshots,damage_per_second,maps_played,round_number,total_kills,total_deaths,fk_team")] player player)
 {
     if (ModelState.IsValid)
     {
         db.Entry(player).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.fk_team = new SelectList(db.teams, "id", "name", player.fk_team);
     return(View(player));
 }
 public ActionResult Edit([Bind(Include = "Id,AccountNumber,AccountBalance,AppUserId,AccTypeId")] AtmAccount atmAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(atmAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AccTypeId = new SelectList(db.AccTypes, "Id", "AccountType", atmAccount.AccTypeId);
     return(View(atmAccount));
 }
Ejemplo n.º 22
0
 public ActionResult EditProduct([Bind(Include = "idProduto,nome,descricao,preco,idCategoria,quantidade,foto,ativo,promo")] Produto produto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(produto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("IndexProduct"));
     }
     ViewBag.idCategoria = new SelectList(db.Categoria, "idCategoria", "nome", produto.idCategoria);
     return(View(produto));
 }
Ejemplo n.º 23
0
 public ActionResult Edit([Bind(Include = "username,userPassword,employeeID,accessLevel")] UserLogin userLogin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userLogin).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.employeeID = new SelectList(db.Employee, "id", "firstName", userLogin.employeeID);
     return(View(userLogin));
 }
Ejemplo n.º 24
0
 public ActionResult Edit([Bind(Include = "Id,UserTypeId,Name,Mail,Password")] UserSet userSet)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userSet).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserTypeId = new SelectList(db.UserTypeSet, "Id", "Title", userSet.UserTypeId);
     return(View(userSet));
 }
Ejemplo n.º 25
0
 public ActionResult Edit([Bind(Include = "Id,UserSetId,AdsId,Pay,Method")] Payment payment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(payment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserSetId = new SelectList(db.UserSet, "Id", "Name", payment.UserSetId);
     ViewBag.AdsId     = new SelectList(db.Ads, "Id", "Name", payment.AdsId);
     return(View(payment));
 }
 public ActionResult Edit([Bind(Include = "Id,UserSetId,AdsId,Name,Title")] Evaluation evaluation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(evaluation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserSetId = new SelectList(db.UserSet, "Id", "Name", evaluation.UserSetId);
     ViewBag.AdsId     = new SelectList(db.Ads, "Id", "Name", evaluation.AdsId);
     return(View(evaluation));
 }
Ejemplo n.º 27
0
 public ActionResult Edit([Bind(Include = "id,name,wins,defeats,maps_played,round_number,total_kills,total_deaths,fk_match,fk_player")] team team)
 {
     if (ModelState.IsValid)
     {
         db.Entry(team).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.fk_match  = new SelectList(db.matches, "id", "map", team.fk_match);
     ViewBag.fk_player = new SelectList(db.players, "id", "first_name", team.fk_player);
     return(View(team));
 }
Ejemplo n.º 28
0
 public ActionResult Edit([Bind(Include = "id,coefficient,fk_users_bets,fk_match")] betting betting)
 {
     if (ModelState.IsValid)
     {
         db.Entry(betting).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.fk_users_bets = new SelectList(db.users_bets, "id", "id", betting.fk_users_bets);
     ViewBag.fk_match      = new SelectList(db.matches, "id", "map", betting.fk_match);
     return(View(betting));
 }
Ejemplo n.º 29
0
 public ActionResult Edit([Bind(Include = "employeeId,branchId,department,position")] WorksAt worksAt)
 {
     if (ModelState.IsValid)
     {
         db.Entry(worksAt).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.branchId   = new SelectList(db.Branch, "id", "branchName", worksAt.branchId);
     ViewBag.employeeId = new SelectList(db.Employee, "id", "firstName", worksAt.employeeId);
     return(View(worksAt));
 }
 public ActionResult Edit([Bind(Include = "Id,TransAmount,TransDate,TransTypeId,AtmAccountId")] Transaction transaction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transaction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AtmAccountId = new SelectList(db.AtmAccounts, "Id", "AccountNumber", transaction.AtmAccountId);
     ViewBag.TransTypeId  = new SelectList(db.TransTypes, "Id", "TransactionType", transaction.TransTypeId);
     return(View(transaction));
 }