public ActionResult Edit(tbl_vinay vinay) { if (vinay.UserImagefile != null) { string fileName = Path.GetFileNameWithoutExtension(vinay.UserImagefile.FileName); string extension = Path.GetExtension(vinay.UserImagefile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssff") + extension; vinay.ImagePath = "~/Image/" + fileName; fileName = Path.Combine(Server.MapPath("~/Image/"), fileName); vinay.UserImagefile.SaveAs(fileName); } if (vinay.ImagePath == null) { vinay.ImagePath = "/Content/Images/No_Image_Available.jpg"; } tryContext context = new tryContext(); context.Entry(vinay).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult created(tbl_vinay vinay) { string path = Server.MapPath("~/App_Data/File"); string filename = Path.GetFileName(vinay.UserImagefile.FileName); string fullpath = Path.Combine(path, filename); vinay.UserImagefile.SaveAs(fullpath); tryContext context = new tryContext(); context.tbl_vinay.Add(vinay); context.SaveChanges(); return(View()); }