示例#1
0
        public ActionResult Create(Tbl_SellerProduct category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(category.ImgFile.FileName);
                    string extension = Path.GetExtension(category.ImgFile.FileName);
                    fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    category.SProductImage = "~/SProductImg/" + fileName;
                    fileName = Path.Combine(Server.MapPath("~/SProductImg/"), fileName);
                    category.ImgFile.SaveAs(fileName);

                    category.SCreatedDate = DateTime.Now;
                    int temp = (int)(Session["BId"]);
                    category.BId = (int)(Session["BId"]);

                    db.Tbl_SellerProduct.Add(category);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                // TODO: Add insert logic here
                return(View(category));
            }
            catch
            {
                return(View());
            }
        }
示例#2
0
        public ActionResult Edit(Tbl_SellerProduct category)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(category.ImgFile.FileName);
                    string extension = Path.GetExtension(category.ImgFile.FileName);
                    fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                    category.SProductImage = "~/ProductImg/" + fileName;
                    fileName = Path.Combine(Server.MapPath("~/ProductImg/"), fileName);
                    category.ImgFile.SaveAs(fileName);

                    category.SModifiedDate = DateTime.Now;

                    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 ActivateSeller(int id)
        {
            var user = db.Tbl_BuyerProfile.Find(id);

            user.IsSellerActivated = true;
            user.BModifiedDate     = DateTime.Now;
            user.BConfirmPassword  = user.BPassword;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        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());
            }
        }
示例#5
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));
        }
示例#6
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());
        }
        // GET: SellerProduct/Create
        //[HttpGet]
        //public ActionResult Create()
        //{
        //    List<Tbl_Category> list = db.Tbl_Category.ToList();
        //    ViewBag.Catelist = new SelectList(list, "CategoryId", "CategoryName");
        //    return View();
        //}

        //// POST: SellerProduct/Create
        //[HttpPost]
        //public ActionResult Create(Tbl_SellerProduct category)
        //{
        //    try
        //    {
        //        if (ModelState.IsValid)
        //        {
        //            string fileName = Path.GetFileNameWithoutExtension(category.ImgFile.FileName);
        //            string extension = Path.GetExtension(category.ImgFile.FileName);
        //            fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
        //            category.SProductImage = "~/SProductImg/" + fileName;
        //            fileName = Path.Combine(Server.MapPath("~/SProductImg/"), fileName);
        //            category.ImgFile.SaveAs(fileName);

        //            category.SCreatedDate = DateTime.Now;

        //            db.Tbl_SellerProduct.Add(category);
        //            db.SaveChanges();
        //            return RedirectToAction("Index");
        //        }
        //        // TODO: Add insert logic here
        //        return View(category);
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        // GET: SellerProduct/Edit/5

        //public ActionResult Edit(int id)
        //{
        //    return View();
        //}

        //// POST: SellerProduct/Edit/5
        //[HttpPost]
        //public ActionResult Edit(int id, FormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add update logic here

        //        return RedirectToAction("Index");
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        // GET: SellerProduct/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tbl_SellerProduct cat = db.Tbl_SellerProduct.Find(id);

            db.Tbl_SellerProduct.Remove(cat);
            db.SaveChanges();
            if (cat == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("Index"));
        }
 public ActionResult Create(Tbl_District category)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Tbl_District.Add(category);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         // TODO: Add insert logic here
         return(View(category));
     }
     catch
     {
         return(View());
     }
 }
示例#9
0
 public ActionResult Create(Tbl_Category category)
 {
     try
     {
         if (ModelState.IsValid)
         {
             category.CreatedDate = DateTime.Now;
             db.Tbl_Category.Add(category);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         // TODO: Add insert logic here
         return(View(category));
     }
     catch
     {
         return(View());
     }
 }
示例#10
0
 public ActionResult Comment(Tbl_Comment category)
 {
     try
     {
         if (ModelState.IsValid)
         {
             category.CommentDate = DateTime.Now;
             category.BId         = (int)Session["BId"];
             category.BLogId      = (int)(Session["ID"]);
             db.Tbl_Comment.Add(category);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         // TODO: Add insert logic here
         return(View(category));
     }
     catch
     {
         return(View());
     }
 }
示例#11
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());
        }
示例#12
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));
        }