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());
            }
        }
예제 #2
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (dbMyEFarmingProjectEntities dc = new dbMyEFarmingProjectEntities())
                {
                    var user = dc.Tbl_BuyerProfile.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.BPassword         = Crypto.Hash(model.NewPassword);
                        user.ResetPasswordCode = "";
                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "New password updated successfully";
                    }
                }
            }
            else
            {
                message = "Something invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
예제 #3
0
        public ActionResult ForgotPassword(string EmailID)
        {
            //Verify Email ID
            //Generate Reset password link
            //Send Email
            string message = "";
            bool   status  = false;

            using (dbMyEFarmingProjectEntities dc = new dbMyEFarmingProjectEntities())
            {
                var account = dc.Tbl_BuyerProfile.Where(a => a.BEmailId == EmailID).FirstOrDefault();
                if (account != null)
                {
                    //Send email for reset password
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.BEmailId, resetCode, "ResetPassword");
                    account.ResetPasswordCode = resetCode;
                    //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property
                    //in our model class in part 1
                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset password link has been sent to your email id.";
                }
                else
                {
                    message = "Account not found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
예제 #4
0
        public ActionResult ResetPassword(string id)
        {
            //Verify the reset password link
            //Find account associated with this link
            //redirect to reset password page
            if (string.IsNullOrWhiteSpace(id))
            {
                return(HttpNotFound());
            }

            using (dbMyEFarmingProjectEntities dc = new dbMyEFarmingProjectEntities())
            {
                var user = dc.Tbl_BuyerProfile.Where(a => a.ResetPasswordCode == id).FirstOrDefault();
                if (user != null)
                {
                    ResetPasswordModel model = new ResetPasswordModel();
                    model.ResetCode = id;
                    return(View(model));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
        }
 public ActionResult ProductOwnerProfile(int id)
 {
     using (dbMyEFarmingProjectEntities db = new dbMyEFarmingProjectEntities())
     {
         var profile = db.Tbl_BuyerProfile.Single(x => x.BId == id);
         return(View(profile));
     }
 }
예제 #6
0
 public bool IsEmailExist(string emailID)
 {
     using (dbMyEFarmingProjectEntities db = new dbMyEFarmingProjectEntities())
     {
         var v = db.Tbl_BuyerProfile.Where(a => a.BEmailId == emailID).FirstOrDefault();
         return(v != null);
     }
 }
        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));
        }
예제 #8
0
        public ActionResult BuyerLogin(BuyerLogin login, string ReturnUrl = "")
        {
            string message = "";

            using (dbMyEFarmingProjectEntities dc = new dbMyEFarmingProjectEntities())
            {
                var v = dc.Tbl_BuyerProfile.Where(a => a.BEmailId == login.BEmailId).FirstOrDefault();
                Session["BId"]          = v.BId;
                Session["RoleAsBuyer"]  = v.IsBuyerActivated;
                Session["RoleAsSeller"] = v.IsSellerActivated;
                if (v != null)
                {
                    if (!v.BIsEmailVarified)
                    {
                        ViewBag.Message = "Please verify your email first";
                        return(View());
                    }
                    if (string.Compare(Crypto.Hash(login.BPassword), v.BPassword) == 0)
                    {
                        int    timeout   = login.RememberMe ? 525600 : 20; // 525600 min = 1 year
                        var    ticket    = new FormsAuthenticationTicket(login.BEmailId, login.RememberMe, timeout);
                        string encrypted = FormsAuthentication.Encrypt(ticket);
                        var    cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
                        cookie.Expires  = DateTime.Now.AddMinutes(timeout);
                        cookie.HttpOnly = true;
                        Response.Cookies.Add(cookie);


                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "BuyerProduct"));
                        }
                    }
                    else
                    {
                        message = "Invalid credential provided";
                    }
                }
                else
                {
                    message = "Invalid credential provided";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
 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));
     }
 }
예제 #10
0
        public ActionResult BuyerRegister()
        {
            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");
            }

            //dbMyEFarmingProjectEntities db = new dbMyEFarmingProjectEntities();
            //List<Tbl_BuyerProfile> list = db.Tbl_BuyerProfile.ToList();
            //ViewBag.NidTypelist = new SelectList(list, "NidTypeId", "NidType");

            return(View());
        }
        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));
            }
        }
예제 #12
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (dbMyEFarmingProjectEntities dc = new dbMyEFarmingProjectEntities())
            {
                dc.Configuration.ValidateOnSaveEnabled = false; // This line I have added here to avoid
                                                                // Confirm password does not match issue on save changes
                var v = dc.Tbl_BuyerProfile.Where(a => a.BActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.BIsEmailVarified = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }
예제 #13
0
        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));
        }