public ActionResult Edit([Bind(Include = "id,adress,prize,detial")] HousePropertyModels housePropertyModels) { UserModels userModels = new UserModels(); if (Session["userid"] != null) { userModels = db.User.Find(Session["userid"]); ViewBag.userModels = userModels; } else { return(RedirectToAction("Login", "User")); } housePropertyModels.propertyUrl1 = Request["propertyUrl1"]; housePropertyModels.propertyUrl2 = Request["propertyUrl2"]; housePropertyModels.propertyUrl3 = Request["propertyUrl3"]; int oareaid = int.Parse(Request["oareaid"]); if (ModelState.IsValid) { if (Request["areaid"] != null) { int areaid = int.Parse(Request["areaid"]); db.Entry(housePropertyModels).State = EntityState.Modified; db.SaveChanges(); db.Database.ExecuteSqlCommand("update HousePropertyModels set area_id=" + areaid + " where id=" + housePropertyModels.id); return(RedirectToAction("userPropertyList")); } else { ModelState.AddModelError("areaid", "地址未选全!"); } } int aid = 0; if (Request["areaid"] == null) { aid = int.Parse(Request["oareaid"]); } else { aid = int.Parse(Request["areaid"]); } List <ProvincesModels> provincesModelsList = db.Provinces.ToList(); ViewBag.provincesModelsList = provincesModelsList; AreasModels areasModels = db.Areas.Find(aid); CitiesModels citiesModels = db.Cities.Where(m => m.cityid == areasModels.cityid).FirstOrDefault(); ProvincesModels provincesModels = db.Provinces.Where(m => m.provinceid == citiesModels.provinceid).FirstOrDefault(); List <CitiesModels> citiesModelsList = db.Cities.Where(m => m.provinceid == provincesModels.provinceid).ToList(); List <AreasModels> areasModelsList = db.Areas.Where(m => m.cityid == citiesModels.cityid).ToList(); ViewBag.citiesModelsList = citiesModelsList; ViewBag.areasModelsList = areasModelsList; ViewBag.citiesModels = citiesModels; ViewBag.provincesModels = provincesModels; housePropertyModels.area = areasModels; housePropertyModels.owner = userModels; return(View(housePropertyModels)); }
public IHttpActionResult PutUser(int id, User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user.User_ID) { return(BadRequest()); } db.Entry(user).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Generic Delete method for the entities /// </summary> /// <param name="entityToDelete"></param> public virtual void Delete(TEntity entityToDelete) { if (Context.Entry(entityToDelete).State == EntityState.Detached) { DbSet.Attach(entityToDelete); } DbSet.Remove(entityToDelete); }
public ActionResult UserEdit(UserModels userInfo) { List <MenuItem> menuList = menu.getAdminMenu(); foreach (MenuItem item in menuList) { if (item.url.Equals("/Admin/UserManage")) { item.active = true; } } ViewBag.menuList = menuList; if (Session["adminid"] != null) { AdminModels adminModels = db.Admin.Find(Session["adminid"]); ViewBag.adminModels = adminModels; } else { return(RedirectToAction("Login")); } if (ModelState.IsValid) { if (Request["areaid"] != null) { int areaid = int.Parse(Request["areaid"]); db.Entry(userInfo).State = EntityState.Modified; db.Database.ExecuteSqlCommand("update UserModels set area_id=" + areaid + " where id=" + userInfo.id); db.SaveChanges(); return(RedirectToAction("UserManage")); } } int aid = 0; if (Request["areaid"] == null) { aid = int.Parse(Request["oareaid"]); } else { aid = int.Parse(Request["areaid"]); } List <ProvincesModels> provincesModelsList = db.Provinces.ToList(); ViewBag.provincesModelsList = provincesModelsList; AreasModels areasModels = db.Areas.Find(aid); CitiesModels citiesModels = db.Cities.Where(m => m.cityid == areasModels.cityid).FirstOrDefault(); ProvincesModels provincesModels = db.Provinces.Where(m => m.provinceid == citiesModels.provinceid).FirstOrDefault(); List <CitiesModels> citiesModelsList = db.Cities.Where(m => m.provinceid == provincesModels.provinceid).ToList(); List <AreasModels> areasModelsList = db.Areas.Where(m => m.cityid == citiesModels.cityid).ToList(); ViewBag.citiesModelsList = citiesModelsList; ViewBag.areasModelsList = areasModelsList; ViewBag.citiesModels = citiesModels; ViewBag.provincesModels = provincesModels; userInfo.area = areasModels; return(View(userInfo)); }
public ActionResult Editar(Pessoa usuario) { db.Pessoa.Add(usuario); //db.Usuario.AddOrUpdate(usuario) tomar cuidado //Manipulando db.Entry(usuario).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Listar")); }
public ActionResult editUserInfo(UserModels userModels) { List <MenuItem> menuList = menu.getUserMenu(); foreach (MenuItem item in menuList) { if (item.url.Equals("/User/showUserInfo")) { item.active = true; } } ViewBag.menuList = menuList; ViewBag.userModels = userModels; if (ModelState.IsValid) { if (Request["areaid"] != null) { int areaid = int.Parse(Request["areaid"]); db.Entry(userModels).State = EntityState.Modified; db.Database.ExecuteSqlCommand("update UserModels set area_id=" + areaid + " where id=" + userModels.id); db.SaveChanges(); return(RedirectToAction("showUserInfo")); } else { ModelState.AddModelError("areaid", "地址未选全!"); } } int aid = 0; if (Request["areaid"] == null) { aid = int.Parse(Request["oareaid"]); } else { aid = int.Parse(Request["areaid"]); } List <ProvincesModels> provincesModelsList = db.Provinces.ToList(); ViewBag.provincesModelsList = provincesModelsList; AreasModels areasModels = db.Areas.Find(aid); CitiesModels citiesModels = db.Cities.Where(m => m.cityid == areasModels.cityid).FirstOrDefault(); ProvincesModels provincesModels = db.Provinces.Where(m => m.provinceid == citiesModels.provinceid).FirstOrDefault(); List <CitiesModels> citiesModelsList = db.Cities.Where(m => m.provinceid == provincesModels.provinceid).ToList(); List <AreasModels> areasModelsList = db.Areas.Where(m => m.cityid == citiesModels.cityid).ToList(); ViewBag.citiesModelsList = citiesModelsList; ViewBag.areasModelsList = areasModelsList; ViewBag.citiesModels = citiesModels; ViewBag.provincesModels = provincesModels; userModels.area = areasModels; return(View(userModels)); }
public IHttpActionResult PutItem(int id, Item item) { if (id != item.ItemId) { return(BadRequest()); } db.Entry(item).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutDepartamento(int id, Departamento departamento) { if (id != departamento.Id) { return(BadRequest()); } db.Entry(departamento).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DepartamentoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Putdog(int id, dog dog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != dog.dogsID) { return(BadRequest()); } db.Entry(dog).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!dogExists(id)) { return(NotFound()); } else { throw; } } return(Ok(HttpStatusCode.NoContent)); }
public IHttpActionResult PutCustomer(int id, Customer customer) { if (id != customer.CustID) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutParentTask(int id, ParentTask parentTask) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != parentTask.Parent_ID) { return(BadRequest()); } db.Entry(parentTask).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ParentTaskExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
internal ULoginResp UserLoginAction(ULoginData data) { UDbTable result; var validate = new EmailAddressAttribute(); if (validate.IsValid(data.Credential)) { var pass = LoginHelper.HashGen(data.Password); using (var db = new DBModels()) { result = db.UDbTables.FirstOrDefault(u => u.Email == data.Credential && u.Password == pass); } if (result == null) { return(new ULoginResp { Status = false, StatusMsg = "The Username or Password is Incorrect" }); } using (var todo = new DBModels()) { result.LasIP = data.LoginIp; result.LastLogin = data.LoginDateTime; todo.Entry(result).State = EntityState.Modified; todo.SaveChanges(); } return(new ULoginResp { Status = true }); } else { var pass = LoginHelper.HashGen(data.Password); using (var db = new DBModels()) { result = db.UDbTables.FirstOrDefault(u => u.Username == data.Credential && u.Password == pass); } if (result == null) { return(new ULoginResp { Status = false, StatusMsg = "The Username or Password is Incorrect" }); } using (var todo = new DBModels()) { result.LasIP = data.LoginIp; result.LastLogin = data.LoginDateTime; todo.Entry(result).State = EntityState.Modified; todo.SaveChanges(); } return(new ULoginResp { Status = true }); } }
public IHttpActionResult PutQualification(int id, Qualification qualification) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != qualification.Index) { return(BadRequest()); } db.Entry(qualification).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!QualificationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutProduct(int id, Product product) { if (id != product.ProductID) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutLocacao(int id, Locacao locacao) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != locacao.Id) { return(BadRequest()); } db.Entry(locacao).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LocacaoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutEmployee(int id, Employee employee) { if (id != employee.EmployeeID) { return(BadRequest()); } db.Entry(employee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void UpdateOutput(Participant model) { using (DBModels db = new DBModels()) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); } }
public ActionResult Edit(topic topicModel) { using (DBModels dbModels = new DBModels()) { dbModels.Entry(topicModel).State = System.Data.Entity.EntityState.Modified; dbModels.SaveChanges(); } return(RedirectToAction("index")); }
public IHttpActionResult PostOrder(Order order) { try { //Order table if (order.OrderID == 0) { db.Orders.Add(order); } else { db.Entry(order).State = EntityState.Modified; } //OrderItems table foreach (var item in order.OrderItems) { if (item.OrderItemID == 0) { db.OrderItems.Add(item); } else { db.Entry(item).State = EntityState.Modified; } } //Delete for OrderItems foreach (var id in order.DeletedOrderItemIDs.Split(',').Where(x => x != "")) { OrderItem x = db.OrderItems.Find(Convert.ToInt64(id)); db.OrderItems.Remove(x); } db.SaveChanges(); return(Ok()); } catch (Exception ex) { throw ex; } }
public ActionResult Edit(product productModel) { using (DBModels dbmodel = new DBModels()) { dbmodel.Entry(productModel).State = System.Data.Entity.EntityState.Modified; dbmodel.SaveChanges(); } return(RedirectToAction("index")); }
public ActionResult Edit([Bind(Include = "Id,Nombre,Apellido,Cedula,Foto,Direccion,Telefono,Sexo,Edad,Fecha_Nacimiento,Afiliados,Membresia,Lugar_Trabajo,Direc_Oficina,Tel_Oficina,Estatus,Fecha_Ingreso,Fecha_Salida")] Socios socios) { if (ModelState.IsValid) { db.Entry(socios).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(socios)); }
public ActionResult Edit([Bind(Include = "MaLoaiSP,TenLoai,MoTa,URLAnh")] LoaiSP loaiSP) { if (ModelState.IsValid) { db.Entry(loaiSP).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loaiSP)); }
public ActionResult Edit([Bind(Include = "AppointmentID,EmployeeID,EmployeeName,CustomerID,Address,Eircode,Start,End,Description")] servicehistory servicehistory) { if (ModelState.IsValid) { db.Entry(servicehistory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(servicehistory)); }
public ActionResult Edit([Bind(Include = "MaNCC,Ten,DiaChi,SDT,Email")] NhaCC nhaCC) { if (ModelState.IsValid) { db.Entry(nhaCC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhaCC)); }
public ActionResult Edit([Bind(Include = "MaKM,TienKM,TiLeKM")] BangKhuyenMai bangKhuyenMai) { if (ModelState.IsValid) { db.Entry(bangKhuyenMai).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bangKhuyenMai)); }
public ActionResult Edit([Bind(Include = "MaND,SDT,GioiTinh,Tuoi,DiaChi,UserName,Email,Pass,MaLoaiND,TenND")] NguoiDung nguoiDung) { if (ModelState.IsValid) { db.Entry(nguoiDung).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaLoaiND = new SelectList(db.LoaiNDs, "MaLoaiND", "TenLoai", nguoiDung.MaLoaiND); return(View(nguoiDung)); }
public ActionResult Edit([Bind(Include = "Id,firstName,lastName,phoneNumber,email,username,password,roleId,dateCreated")] Users user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.roleId = new SelectList(db.userRole, "Id", "role", user.roleId); return(View(user)); }
public ActionResult Edit(int id, product productModel) { //Edit a product productModel.ProductID = id; using (DBModels dbModel = new DBModels()) { dbModel.Entry(productModel).State = EntityState.Modified; dbModel.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MaSP,TenSP,SoLuong,DonGia,MoTa,GiaKM,URLAnh,MaLoaiSP,MaKM")] SanPham sanPham) { if (ModelState.IsValid) { db.Entry(sanPham).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaKM = new SelectList(db.BangKhuyenMais, "MaKM", "MaKM", sanPham.MaKM); ViewBag.MaLoaiSP = new SelectList(db.LoaiSPs, "MaLoaiSP", "TenLoai", sanPham.MaLoaiSP); return(View(sanPham)); }
public ActionResult Edit([Bind(Include = "Id,firstName,lastName,email,contact,equipmentTypeId,brandId,model,serial,issues,recepId,dateIn,techReport,techId,dateRepaired,statusId,dateCollected,jobNumber")] Jobs jobs) { if (ModelState.IsValid) { db.Entry(jobs).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.brandId = new SelectList(db.Brand, "Id", "brandName", jobs.brandId); ViewBag.equipmentTypeId = new SelectList(db.equiptmentType, "Id", "equiptmentName", jobs.equipmentTypeId); ViewBag.statusId = new SelectList(db.status, "Id", "statusName", jobs.statusId); return(View(jobs)); }