Exemple #1
0
 IEnumerable <Events> GetAll()
 {
     using (DAL.GerminmedContext db = new GerminmedContext())
     {
         return(db.Event.ToList <Events>());
     }
 }
        public ActionResult AddOrEdit(Promotions promo)
        {
            try
            {
                using (GerminmedContext db = new GerminmedContext())
                {
                    if (promo.Id == 0)
                    {
                        db.Promotion.Add(promo);
                        db.SaveChanges();
                    }
                    else
                    {
                        db.Entry(promo).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
                return(Json(data: new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", model: GetAll()), message = "Submitted Successfully" }, behavior: JsonRequestBehavior.AllowGet));

                //RedirectToAction("ViewAll");
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
 IEnumerable <Clients> GetAll()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.Client.ToList <Clients>());
     }
 }
Exemple #4
0
        public ActionResult Delete(int Id)
        {
            try
            {
                using (GerminmedContext db = new GerminmedContext())
                {
                    Products prod = db.Product.Where(x => x.Id == Id).FirstOrDefault <Products>();

                    string fullPath = Request.MapPath(prod.ImagePath);
                    if (prod.ImagePath != "~/AppFiles/Images/Default.png")
                    {
                        if (System.IO.File.Exists(fullPath))
                        {
                            System.IO.File.Delete(fullPath);
                        }
                    }
                    if (prod.Catalogue != null)
                    {
                        string fullPathCatalog = Request.MapPath(prod.Catalogue);
                        if (System.IO.File.Exists(fullPathCatalog))
                        {
                            System.IO.File.Delete(fullPathCatalog);
                        }
                    }

                    db.Product.Remove(prod);
                    db.SaveChanges();
                }
                return(Json(data: new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", model: GetAllProducts()), message = "Deleted Successfully" }, behavior: JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #5
0
        public ActionResult Register(Users userModel)
        {
            using (GerminmedContext db = new GerminmedContext())
            {
                userModel.IsAdmin = false;

                userModel.ActivationCode  = Guid.NewGuid().ToString();
                userModel.IsEmailVerified = false;
                userModel.IsActive        = false;
                if (db.User.Any(x => x.UserName == userModel.UserName))
                {
                    ViewBag.DuplicateMessage = "Username already exist.";
                    return(View("Register", userModel));
                }


                db.User.Add(userModel);
                db.SaveChanges();

                SendVerificationLinkEmail(userModel.Email, userModel.ActivationCode.ToString(), "VerifyAccount");
                ViewBag.SuccessMessage = "Germin MED Welcome you to Our online shopping. Email verification link " +
                                         " has been sent to your email :" + userModel.Email;
            }
            ModelState.Clear();
            // ViewBag.SuccessMessage = "Registration Successful.";
            return(View("Success"));
        }
Exemple #6
0
 IEnumerable <Brands> GeAllBrandsList()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.Brand.ToList <Brands>());
     }
 }
Exemple #7
0
 IEnumerable <Branches> GetAll()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.Branch.ToList <Branches>());
     }
 }
Exemple #8
0
 IEnumerable <Category> GetAllCat()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.Category.ToList <Category>());
     }
 }
 IEnumerable <NewsLetter> GetAll()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.NewsLetters.ToList <NewsLetter>());
     }
 }
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (GerminmedContext db = new GerminmedContext())
                {
                    var user = db.User.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.Password          = model.NewPassword;
                        user.ResetPasswordCode = "";
                        db.Configuration.ValidateOnSaveEnabled = false;
                        db.SaveChanges();
                        message = "New password updated successfully";
                    }
                }
            }
            else
            {
                message = "Something invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
Exemple #11
0
        IEnumerable <Category> GetAllCatByRootCat(int?id)
        {
            List <Category> catList     = new List <Category>();
            List <Category> catListcopy = new List <Category>();

            using (GerminmedContext db = new GerminmedContext())
            {
                if (id != null)
                {
                    catList = db.Category.SqlQuery(Category.sqlQuery1).Where(x => x.ParentId == id).ToList <Category>();


                    //foreach (var item in catList)
                    //{
                    //    catListcopy.AddRange(db.Category.SqlQuery(Category.sqlQuery1).Where(x => x.ParentId == item.Id).ToList<Category>());
                    //}

                    catList.AddRange(catListcopy);
                    return(catList);
                }
                else
                {
                    return(null);
                }
            }
        }
        public ActionResult ForgotPassword(string EmailID)
        {
            //Verify Email ID
            //Generate Reset password link
            //Send Email
            string message = "";
            bool   status  = false;

            using (GerminmedContext db = new GerminmedContext())
            {
                var account = db.User.Where(a => a.Email == EmailID).FirstOrDefault();
                if (account != null)
                {
                    //Send email for reset password
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.Email, 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
                    db.Configuration.ValidateOnSaveEnabled = false;
                    db.SaveChanges();
                    message = "Reset password link has been sent to your email id.";
                }
                else
                {
                    message = "Account not found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
        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 (GerminmedContext db = new GerminmedContext())
            {
                var user = db.User.Where(a => a.ResetPasswordCode == id).FirstOrDefault();
                if (user != null)
                {
                    ResetPasswordModel model = new ResetPasswordModel();
                    model.ResetCode = id;
                    return(View(model));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
        }
 IEnumerable <Banner> GetAll()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.Banners.ToList <Banner>());
     }
 }
Exemple #15
0
 public ActionResult DeleteImage(int Id, int productid)
 {
     try
     {
         using (GerminmedContext db = new GerminmedContext())
         {
             ProductImage img      = db.ProductImage.Where(x => x.Id == Id).FirstOrDefault <ProductImage>();
             string       fullPath = Request.MapPath(img.ImageUrl);
             if (img.ImageUrl != "~/AppFiles/Images/Default.png")
             {
                 if (System.IO.File.Exists(fullPath))
                 {
                     System.IO.File.Delete(fullPath);
                 }
             }
             db.ProductImage.Remove(img);
             db.SaveChanges();
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewImagesByProduct", GetAllImagesByProduct(productid)), message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #16
0
 IEnumerable <ProductImage> GetAllImagesByProduct(int id)
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.ProductImage.Where(x => x.ProductId == id).ToList <ProductImage>());
     }
 }
Exemple #17
0
 IEnumerable <Users> GetAllRegisteredUser()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.User.Where(x => x.UserTypeId == 1).ToList <Users>());
     }
 }
        public ActionResult OrederConfirm(UserViewModel uvm)
        {
            if (Session["cart"] != null && Session["UserId"] != null)
            {
                string       firstName         = uvm.FirstName;
                string       userName          = Session["userName"].ToString();
                string       phone             = uvm.Phone;
                string       cartTableForEmail = "";
                string       ToEmail           = uvm.Email;
                List <Cart>  cart      = (List <Cart>)Session["cart"];
                List <Order> orderList = new List <Order>();

                foreach (var item in cart)
                {
                    Order orderModel = new Order();
                    orderModel.ProductId = item.Product.Id;
                    orderModel.UserId    = (int)Session["UserId"];
                    orderModel.Qty       = item.Quantity;
                    orderList.Add(orderModel);
                    cartTableForEmail = cartTableForEmail + "<tr><td>" + item.Product.ProductName + "</td><td>" + item.Quantity + "</td><td>" + item.Product.Price + "</td></tr>";
                }
                using (GerminmedContext db = new GerminmedContext())
                {
                    db.Orders.AddRange(orderList);
                    db.SaveChanges();
                }
                SendEmail(firstName, userName, phone, cartTableForEmail);
                SendEmail(firstName, userName, phone, cartTableForEmail, ToEmail);
            }
            Session["cart"] = null;
            return(View());
        }
Exemple #19
0
 public ActionResult Index1()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(View(db.Banners.ToList <Banner>()));
     }
 }
        public ActionResult ChangePassword(UserViewModel usr)
        {
            try
            {
                using (GerminmedContext db = new GerminmedContext())
                {
                    var currentItem = db.User.Where(b => b.Id == usr.Id).FirstOrDefault <Users>();
                    if (currentItem.Password == usr.OldPassword)
                    {
                        currentItem.Password = usr.Password;
                        //  currentItem.OldPassword = usr.OldPassword;
                        currentItem.ConfirmPassword = usr.ConfirmPassword;
                        db.Entry(currentItem).State = EntityState.Modified;
                        db.SaveChanges();

                        return(Json(data: new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ChangePassword", model: usr), message = "Password changed Successfully" }, behavior: JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { success = false, message = "Wrong Old password" }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #21
0
        public ActionResult ProductSub(int Id = 0, string Name = "")
        {
            if (Id > 0)
            {
                ViewBag.CategoryId = Id;
            }
            else if (string.IsNullOrEmpty(Name) == false)
            {
                Id = GetCategoryId(Name);
                Url.RequestContext.RouteData.Values["id"] = Id;
            }

            using (GerminmedContext db = new GerminmedContext())
            {
                ViewBag.CategoryInnerBanner = db.Category.Where(x => x.Id == Id).FirstOrDefault();
            }

            IEnumerable <Category> cat = GetAllCatByParent(Id);

            return(View(cat));
            //if (cat.Count() != 0)
            //    return View(cat);
            //else
            //{
            //    return RedirectToAction("Products", "Product",new {Id=Id });
            //}
        }
 IEnumerable <Promotions> GetAll()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         return(db.Promotion.ToList <Promotions>());
     }
 }
 public ActionResult Delete(int Id)
 {
     try
     {
         using (GerminmedContext db = new GerminmedContext())
         {
             NewsLetter news     = db.NewsLetters.Where(x => x.Id == Id).FirstOrDefault <NewsLetter>();
             string     fullPath = Request.MapPath(news.ImageUrl);
             if (news.ImageUrl != "~/AppFiles/Images/Default.png")
             {
                 if (System.IO.File.Exists(fullPath))
                 {
                     System.IO.File.Delete(fullPath);
                 }
             }
             db.NewsLetters.Remove(news);
             db.SaveChanges();
         }
         return(Json(data: new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", model: GetAll()), message = "Deleted Successfully" }, behavior: JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #24
0
        public ActionResult Approve(int Id)
        {
            try
            {
                using (GerminmedContext db = new GerminmedContext())
                {
                    db.Configuration.ValidateOnSaveEnabled = false;
                    Users usr = db.User.Where(x => x.Id == Id).FirstOrDefault <Users>();



                    if (usr.IsActive == false)
                    {
                        usr.IsActive = true;
                    }

                    //
                    //entities.Entry(user).Property(u => u.LastActivity).IsModified = true;
                    //entities.SaveChanges();

                    db.User.Attach(usr);
                    db.Entry(usr).Property(x => x.IsActive).IsModified = true;
                    db.SaveChanges();
                    SendVerificationLinkEmail(usr.Email, "", "Approve");
                }

                return(Json(data: new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAllRegisteredUser", model: GetAllRegisteredUser()), message = "Updated Successfully" }, behavior: JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #25
0
        public ActionResult Index(string name, string email, string phone, string message)
        {
            string       fromEmail, toEmail, password, server;
            int          port;
            bool         isSslEnable;
            MailSettings mailmodel = new MailSettings();

            using (GerminmedContext db = new GerminmedContext())
            {
                mailmodel = db.MailSetting.FirstOrDefault();
            }

            if (mailmodel != null)
            {
                fromEmail   = mailmodel.Username;
                toEmail     = mailmodel.Contact;
                password    = mailmodel.Password;
                server      = mailmodel.Server;
                port        = mailmodel.Port;
                isSslEnable = mailmodel.IsSSLEnabled;
            }
            else
            {
                fromEmail   = ConfigurationManager.AppSettings["EmailFromAddress"];
                toEmail     = ConfigurationManager.AppSettings["MailAuthUser"];
                password    = ConfigurationManager.AppSettings["MailAuthPass"];
                server      = ConfigurationManager.AppSettings["MailServer"];
                port        = int.Parse(ConfigurationManager.AppSettings["Port"]);
                isSslEnable = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSSL"]);
            }


            try
            {
                using (MailMessage mm = new MailMessage(fromEmail, toEmail))
                {
                    mm.Subject    = "GerminMed Contact Customer Information ";
                    mm.Body       = CreateBody(name, email, phone, message);
                    mm.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host      = server;
                    smtp.EnableSsl = isSslEnable;

                    NetworkCredential NetworkCred = new NetworkCredential(fromEmail, password);
                    smtp.UseDefaultCredentials = isSslEnable;
                    smtp.Credentials           = NetworkCred;
                    smtp.Port = port;
                    smtp.Send(mm);
                    ViewBag.Succcess = "Contact Mail Send, Thank you for your Time.";
                }

                return(View());
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Error : " + ex.Message;
                return(View());
            }
        }
 // GET: AboutUs
 public ActionResult Index()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         InnerBanner bnr = new InnerBanner();
         bnr = db.InnerBanners.Where(x => x.PageName == "AboutUs").FirstOrDefault();
         return(View(bnr));
     }
 }
 IEnumerable <Events> GetAll()
 {
     using (GerminmedContext db = new GerminmedContext())
     {
         InnerBanner bnr = new InnerBanner();
         ViewBag.InnerBanner = db.InnerBanners.Where(x => x.PageName == "Events").FirstOrDefault();
         return(db.Event.ToList <Events>());
     }
 }
Exemple #28
0
        IEnumerable <ProductViewModel> GetAllProductsByBrands(int?brandId, int categoryId)
        {
            List <ProductViewModel> ProductVMlist = new List <ProductViewModel>();

            allSubCats = new List <int>();
            using (GerminmedContext db = new GerminmedContext())
            {
                if (brandId > 0)
                {
                    GetChilds(categoryId);
                }

                var productlist = (from prod1 in db.Product
                                   join img in db.ProductImage on prod1.Id equals img.ProductId
                                   join brnd in db.Brand on prod1.BrandId equals brnd.Id
                                   orderby img.DisplayOrder ascending
                                   select new
                {
                    prod1.Id,
                    prod1.ProductName,
                    prod1.Description,
                    prod1.IsFeatured,
                    prod1.IsOffer,
                    prod1.OfferPercentage,
                    prod1.ShowInHomePage,
                    img.ImageUrl,
                    brnd.Title,
                    prod1.BrandId,
                    prod1.CategoryId
                }).ToList();
                if (brandId > 0)
                {
                    productlist = productlist.Where(p => (allSubCats.Contains(p.CategoryId) || p.CategoryId == categoryId) && p.BrandId == brandId).ToList();
                }
                else if (categoryId > 0)
                {
                    productlist = productlist.Where(p => p.CategoryId == categoryId).ToList();
                }

                foreach (var item in productlist)
                {
                    ProductViewModel objHome = new ProductViewModel();// ViewModel
                    objHome.Id              = item.Id;
                    objHome.ProductName     = item.ProductName;
                    objHome.Description     = item.Description;
                    objHome.IsFeatured      = item.IsFeatured;
                    objHome.IsOffer         = item.IsOffer;
                    objHome.OfferPercentage = item.OfferPercentage;
                    objHome.ShowInHomePage  = item.ShowInHomePage;
                    objHome.ImageUrl        = item.ImageUrl;
                    objHome.BrandTitle      = item.Title;
                    ProductVMlist.Add(objHome);
                }
                return(ProductVMlist);
            }
        }
Exemple #29
0
        IEnumerable <Brands> GetAll()
        {
            using (GerminmedContext db = new GerminmedContext())
            {
                InnerBanner bnr = new InnerBanner();
                ViewBag.InnerBanner = db.InnerBanners.Where(x => x.PageName == "Brand").FirstOrDefault();

                return(db.Brand.Where(x => x.ShowInBrandPage == true).ToList <Brands>());
            }
        }
Exemple #30
0
        // GET: Contact
        public ActionResult Index()
        {
            using (GerminmedContext db = new GerminmedContext())
            {
                InnerBanner bnr = new InnerBanner();
                ViewBag.InnerBanner = db.InnerBanners.Where(x => x.PageName == "ContactUs").FirstOrDefault();
            }

            return(View("Index"));
        }