public ActionResult EditProject(tblProject model, List <HttpPostedFileBase> listImage) { foreach (var item in listImage) { if (item == null) { continue; } var newName = item.FileName.Insert(item.FileName.LastIndexOf('.'), $"{DateTime.Now:_ddMMyyyy}"); var path = Server.MapPath("/Uploads/News/" + newName); item.SaveAs(path); var image = new tblImage { Image = newName, URL = "/Uploads/News/" + newName, ProjectId = model.Id, DictionaryId = 47 }; db.tblImage.Add(image); } db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult RealEdit(RealViewModel f, HttpPostedFileBase image) { var r = _db.tblLand.Find(f.Id); if (r == null) { return(HttpNotFound()); } if (!ModelState.IsValid) { return(View(f)); } r.Address = f.Address; r.Area = f.Area; r.Code = f.BlockCode; r.Content = f.Content; r.CustomerId = Auth.User.UserId; r.ProjectId = f.ProjectId; r.Price = f.Price; r.ProvinceId = f.ProvinceId; r.DistrictId = f.DistrictId; r.Title = f.Title; r.Email = f.ClientEmail; r.Phone = f.ClientCellPhone; r.Road = f.Facede; r.CategoryId = f.CategoryId; r.TypeId = f.TypeId; r.RuleId = f.RuleId; r.UnitId = f.UnitId; r.DirectionId = f.DirectionId; if (image.AllowFile()) { if (r.Image != null) { FileExtensions.DeleteFile(r.Image.Split('/').Last(), "~/Uploads/Reals/"); } var newName = image.GetNewFileName(); image.SaveFileToFolder("/Uploads/Reals/", newName); r.Image = "/Uploads/Reals/" + newName; } _db.Entry(r).State = EntityState.Modified; _db.SaveChanges(); TempData["Update"] = "Cập nhật thành công"; return(RedirectToAction("RealEdit", new { Id = r.Id })); }
public ActionResult Update(tblDictionary model) { model.Delete = false; _db.Entry(model).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("/Index/" + model.CategoryId)); }
public ActionResult Update(tblNews model) { _db.Entry(model).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); ViewBag.CateId = new SelectList(_db.tblDictionary.Where(p => p.CategoryId == 6).ToList(), "Id", "Title", model.CateId); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,ProjectId,DictionaryId,Title,Content,Orders")] tblProjectDetail tblProjectDetail) { if (ModelState.IsValid) { db.Entry(tblProjectDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DictionaryId = new SelectList(db.tblDictionary, "Id", "Title", tblProjectDetail.DictionaryId); ViewBag.ProjectId = new SelectList(db.tblProject, "Id", "Title", tblProjectDetail.ProjectId); return(View(tblProjectDetail)); }
public ActionResult EditImageS(tblImage model, HttpPostedFileBase Image) { // Image if (Image != null) { String newName = Image.FileName.Insert(Image.FileName.LastIndexOf('.'), String.Format("{0:_ddMMyyyy}", DateTime.Now)); String path = Server.MapPath("~/Images/Sliders/" + newName); Image.SaveAs(path); model.Image = newName; } db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Index(tblConfig model, HttpPostedFileBase Logo) { // Logo if (Logo != null) { String newName = Logo.FileName.Insert(Logo.FileName.LastIndexOf('.'), String.Format("{0:_ddMMyyyy}", DateTime.Now)); String path = Server.MapPath("~/Images/" + newName); Logo.SaveAs(path); model.Logo = newName; } _db.Entry(model).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(View(model)); }
public ActionResult Update(tblLand model, IEnumerable <HttpPostedFileBase> listImage) { var dba = new LandSoftEntities(); var la = dba.tblLand.Find(model.Id); if (la == null) { return(RedirectToAction("Update")); } foreach (var item in listImage) { if (item == null) { continue; } var newName = item.FileName.Insert(item.FileName.LastIndexOf('.'), $"{DateTime.Now:_ddMMyyyy}"); var path = Server.MapPath("~/Uploads/News/" + newName); item.SaveAs(path); var a = new tblImage { Image = newName, URL = "/Uploads/News/" + newName, LandId = model.Id, DictionaryId = 47 }; db.tblImage.Add(a); } model.Area = string.Empty; model.Area = Request["DienTich"]; model.CustomerId = la.CustomerId; model.CreateDate = la.CreateDate; db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Update(tblNews model) { _db.Entry(model).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }