public ActionResult Edit(Tbl_BuyerProfile category) { dbMyEFarmingProjectEntities db = new dbMyEFarmingProjectEntities(); try { if (ModelState.IsValid) { string fileName = Path.GetFileNameWithoutExtension(category.ImageFile.FileName); string extension = Path.GetExtension(category.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; category.BImage = "~/BImage/" + fileName; fileName = Path.Combine(Server.MapPath("~/BImage/"), fileName); category.ImageFile.SaveAs(fileName); category.BModifiedDate = DateTime.Now; category.NidTypeId = 1; category.DistrictId = 1; db.Entry(category).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } // TODO: Add update logic here return(View(category)); } catch { return(View()); } }
public ActionResult BuyerProfile() { Tbl_BuyerProfile imagemodel = new Tbl_BuyerProfile(); int id = (int)(Session["BId"]); using (dbMyEFarmingProjectEntities db = new dbMyEFarmingProjectEntities()) { imagemodel = db.Tbl_BuyerProfile.Where(x => x.BId == id).FirstOrDefault(); Session["BId"] = imagemodel.BId; } return(View(imagemodel)); }
public ActionResult Edit(int?id) { using (dbMyEFarmingProjectEntities db = new dbMyEFarmingProjectEntities()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbl_BuyerProfile cat = db.Tbl_BuyerProfile.Find(id); if (cat == null) { return(HttpNotFound()); } return(View(cat)); } }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbl_BuyerProfile cat = db.Tbl_BuyerProfile.Find(id); db.Tbl_BuyerProfile.Remove(cat); db.SaveChanges(); if (cat == null) { return(HttpNotFound()); } return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { using (dbMyEFarmingProjectEntities db = new dbMyEFarmingProjectEntities()) { List <Tbl_District> list = db.Tbl_District.ToList(); ViewBag.Dislist = new SelectList(list, "DistrictId", "DistrictType"); List <Tbl_NidType> listt = db.Tbl_NidType.ToList(); ViewBag.Nidlist = new SelectList(listt, "NidTypeId", "NidType"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbl_BuyerProfile cat = db.Tbl_BuyerProfile.Find(id); if (cat == null) { return(HttpNotFound()); } return(View(cat)); } }
public ActionResult BuyerRegister([Bind(Exclude = "BIsEmailVarified,BActivationCode")] Tbl_BuyerProfile model, HttpPostedFileBase file) { bool Status = false; string message = ""; //Model validation if (ModelState.IsValid) { #region //Email is already Exist var isExist = IsEmailExist(model.BEmailId); if (isExist) { ModelState.AddModelError("EmailExist", "Email already exist"); return(View(model)); } #endregion #region Generate Activation Code model.BActivationCode = Guid.NewGuid(); #endregion #region Password Hashing model.BPassword = Crypto.Hash(model.BPassword); model.BConfirmPassword = Crypto.Hash(model.BConfirmPassword); // #endregion model.BIsEmailVarified = false; model.NidTypeId = 1; model.DistrictId = 1; model.BCreatedDate = DateTime.Now; model.IsBuyerActivated = false; model.IsSellerActivated = false; string fileName = Path.GetFileNameWithoutExtension(model.ImageFile.FileName); string extension = Path.GetExtension(model.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; model.BImage = "~/BImage/" + fileName; fileName = Path.Combine(Server.MapPath("~/BImage/"), fileName); model.ImageFile.SaveAs(fileName); #region Save to Database using (dbMyEFarmingProjectEntities dc = new dbMyEFarmingProjectEntities()) { dc.Tbl_BuyerProfile.Add(model); try { dc.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { string t = ("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:" + eve.Entry.Entity.GetType().Name + eve.Entry.State); foreach (var ve in eve.ValidationErrors) { t = ("- Property: \"{0}\"+ Error: \"{1}\"" + ve.PropertyName + ve.ErrorMessage); } } throw; } //Send Email to User SendVerificationLinkEmail(model.BEmailId, model.BActivationCode.ToString()); message = "Registration successfully done. Account activation link " + " has been sent to your email id:" + model.BEmailId; Status = true; } #endregion } else { message = "Invalid Request"; } ViewBag.Message = message; ViewBag.Status = Status; return(View(model)); }