public ActionResult Edit(BDSBank model) { if (!ModelState.IsValid) { ViewBag.Success = false; ViewBag.Message = Resource.SaveFailed; return(View(model)); } BDSBank modelDB = _service.GetItem(model.ID); var path = string.Empty; var path1 = string.Empty; var NewPath = string.Empty; var fortmatName = string.Empty; var fileNameFull = string.Empty; var file = System.Web.HttpContext.Current.Request.Files["UrlImageFile"]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); string newFileNmae = Path.GetFileNameWithoutExtension(fileName); fortmatName = Path.GetExtension(fileName); NewPath = newFileNmae.Replace(newFileNmae, (DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()).ToString()); fileNameFull = DateTime.Now.Day + "" + DateTime.Now.Month + "_" + NewPath + fortmatName; if (Server.MapPath("~/UploadImg/").Contains(ConfigurationManager.AppSettings["HostAdmin"])) { path = Server.MapPath("~/UploadImg/").Replace(ConfigurationManager.AppSettings["HostAdmin"], ConfigurationManager.AppSettings["HostWeb"]) + DateTime.Now.Day + DateTime.Now.Month + "/"; } else { path = Server.MapPath("~/UploadImg/").Replace("Davisoft_BDSProject.Web", "WebBDS_Project") + DateTime.Now.Day + DateTime.Now.Month + "/"; } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path1 = Path.Combine(path, fileNameFull); file.SaveAs(path1); } model.UrlImage = fileNameFull; model.KeySearch = model.Name.NormalizeD() + " " + model.AccountName.NormalizeD() + " " + model.AccountNumber.NormalizeD() + " " + model.Branch.NormalizeD() + " " + (String.IsNullOrEmpty(model.Address) ? "" : model.Address.NormalizeD()) + " " + (String.IsNullOrEmpty(model.Description) ? "" : model.Description.NormalizeD()); _service.UpdateItem(model); ViewBag.Success = true; ViewBag.Message = Resource.SaveSuccessful; return(Edit(model.ID)); }
public ActionResult Edit(int id) { BDSBank model = _service.GetItem(id); return(View(model)); }