public ActionResult Create([Bind(Include = "CategoryId,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(PartialView("Index", db.Categories.ToList()));
            }

            return(PartialView(category));
        }
        public ActionResult Create([Bind(Include = "PharmacyCategoryId,PharmacyCategoryName")] PharmacyCategory pharmacyCategory)
        {
            if (ModelState.IsValid)
            {
                db.PharmacyCategories.Add(pharmacyCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(PartialView(pharmacyCategory));
        }
        public ActionResult Create([Bind(Include = "AddressId,AddressDoorNo,AddressLine1,AddressLine2,LandMark,PinCode,UserId,Name,City,State")] Address address)
        {
            if (ModelState.IsValid)
            {
                db.Addresses.Add(address);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(address));
        }
Exemple #4
0
        public ActionResult Create([Bind(Include = "orderid,orderdate,orderstatus,userid,addressid,paymenttype,paymentstatus,totalamount,orderPlacedId,totalItems")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.orderPlacedId = new SelectList(db.orderPlacedProducts, "orderPlacedId", "orderPlacedHealthProducts", order.orderPlacedId);
            return(View(order));
        }
 public ActionResult Create([Bind(Include = "Product_Id,Product_Name,Product_Price,Product_Details,SubClassificationId,ExpiryDate,Quantity", Exclude = "Product_Image")] Product product, HttpPostedFileBase Product_Image)
 {
     if (ModelState.IsValid)
     {
         if (Product_Image != null)
         {
             if (Product_Image.ContentLength > 0)
             {
                 byte[] imgBinaryData = new byte[Product_Image.ContentLength];
                 int    readresult    = Product_Image.InputStream.Read(imgBinaryData, 0, Product_Image.ContentLength);
                 product.Product_Image = imgBinaryData;
             }
         }
         db.Products.Add(product);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SubClassificationId = new SelectList(db.SubClassifications, "SubClassificationId", "SubClassificationName", product.SubClassificationId);
     return(PartialView(product));
 }
Exemple #6
0
        public ActionResult Create([Bind(Include = "SubClassificationId,SubClassificationName,SubCat_Id", Exclude = "SubClassificationImage")] SubClassification subClassification, HttpPostedFileBase SubClassificationImage)
        {
            if (ModelState.IsValid)
            {
                if (SubClassificationImage != null)
                {
                    if (SubClassificationImage.ContentLength > 0)
                    {
                        byte[] imgBinaryData = new byte[SubClassificationImage.ContentLength];
                        int    readresult    = SubClassificationImage.InputStream.Read(imgBinaryData, 0, SubClassificationImage.ContentLength);
                        subClassification.SubClassificationImage = imgBinaryData;
                    }
                }
                db.SubClassifications.Add(subClassification);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SubCat_Id = new SelectList(db.SubCategories, "SubCat_Id", "SubCatName", subClassification.SubCat_Id);
            return(PartialView(subClassification));
        }
        public ActionResult Create([Bind(Include = "PharmacySubCatId,PharmacySubCatName,PharmacyCategoryId", Exclude = "PharmacySubCatImage")] PharmacySubCategory pharmacySubCategory, HttpPostedFileBase PharmacySubCatImage)
        {
            if (ModelState.IsValid)
            {
                if (PharmacySubCatImage != null)
                {
                    if (PharmacySubCatImage.ContentLength > 0)
                    {
                        byte[] imgBinaryData = new byte[PharmacySubCatImage.ContentLength];
                        int    readresult    = PharmacySubCatImage.InputStream.Read(imgBinaryData, 0, PharmacySubCatImage.ContentLength);
                        pharmacySubCategory.PharmacySubCatImage = imgBinaryData;
                    }
                }
                db.PharmacySubCategories.Add(pharmacySubCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PharmacyCategoryId = new SelectList(db.PharmacyCategories, "PharmacyCategoryId", "PharmacyCategoryName", pharmacySubCategory.PharmacyCategoryId);
            return(PartialView(pharmacySubCategory));
        }
Exemple #8
0
        public ActionResult Create([Bind(Include = "ProductId,ProductName,ProductPrice,ProductDetails,PharmacySubCatId,ExpiryDate,Quantity,ProductType,Manufacturer", Exclude = "ProductImage")] PharmacyProduct pharmacyProduct, HttpPostedFileBase ProductImage)
        {
            if (ModelState.IsValid)
            {
                if (ProductImage != null)
                {
                    if (ProductImage.ContentLength > 0)
                    {
                        byte[] imgBinaryData = new byte[ProductImage.ContentLength];
                        int    readresult    = ProductImage.InputStream.Read(imgBinaryData, 0, ProductImage.ContentLength);
                        pharmacyProduct.ProductImage = imgBinaryData;
                    }
                }
                db.PharmacyProducts.Add(pharmacyProduct);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PharmacySubCatId = new SelectList(db.PharmacySubCategories, "PharmacySubCatId", "PharmacySubCatName", pharmacyProduct.PharmacySubCatId);
            return(PartialView(pharmacyProduct));
        }
Exemple #9
0
        public ActionResult Create(CustomerDetail collection)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    using (starmedsdbEntities db = new starmedsdbEntities())
                    {
                        db.CustomerDetails.Add(collection);
                        db.SaveChanges();
                    }
                    ModelState.Clear();
                    ViewData["SuccessMessage"] = "User Registered Successfully";
                }

                return(View("Index", new CustomerDetail()));
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
            return(View());
        }
        public ActionResult PlaceOrder(string paymentType)
        {
            int addressId = Convert.ToInt32(System.Web.HttpContext.Current.Session["SelectedAddress"]);
            CartProductModel cartProducts = new CartProductModel();

            cartProducts.HealthProducts   = new List <Product>();
            cartProducts.PharmacyProducts = new List <PharmacyProduct>();
            cartProducts.Addresses        = new List <Address>();
            cartProducts.TotalItems       = 0;
            cartProducts.TotalPrice       = 0;

            int UserId = 0;

            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                UserId = Convert.ToInt32(Session["UserID"]);
            }

            //get products from cart table
            var products = db.Carts.Where(c => c.userid == UserId).ToList();

            foreach (var product in products)
            {
                cartProducts.TotalItems++;
                if (product.producttype == "healthproduct")
                {
                    var prod = db.Products.Where(i => i.Product_Id == product.productid).FirstOrDefault();
                    cartProducts.HealthProducts.Add(prod);
                    cartProducts.TotalPrice = cartProducts.TotalPrice + Convert.ToInt32(prod.Product_Price);
                }
                else if (product.producttype == "pharmacyproduct")
                {
                    var prod = db.PharmacyProducts.Where(i => i.ProductId == product.productid).FirstOrDefault();
                    cartProducts.PharmacyProducts.Add(prod);
                    cartProducts.TotalPrice = cartProducts.TotalPrice + Convert.ToInt32(prod.ProductPrice);
                }
            }

            //get adresses from adress table
            var addresses = db.Addresses.Where(c => c.UserId == UserId).ToList();

            cartProducts.Addresses = addresses.Select(i => new Address()
            {
                AddressId     = i.AddressId,
                AddressDoorNo = i.AddressDoorNo,
                AddressLine1  = i.AddressLine1,
                AddressLine2  = i.AddressLine2,
                LandMark      = i.LandMark,
                PinCode       = i.PinCode,
                UserId        = i.UserId,
                Name          = i.Name,
                City          = i.City,
                State         = i.State
            }).ToList();;
            Session["count"] = db.Carts.Where(c => c.userid == UserId).Count();
            if (paymentType == null)
            {
                ViewBag.message = "Select Payment Method";
                return(View("FinalStep", cartProducts));
            }
            else
            {
                if (paymentType == "cod")
                {
                    orderPlacedProduct orderpp            = new orderPlacedProduct();
                    string             orderedhp_products = string.Empty;
                    foreach (var item in cartProducts.HealthProducts)
                    {
                        if (string.IsNullOrEmpty(orderedhp_products))
                        {
                            orderedhp_products = item.Product_Id.ToString();
                        }
                        else
                        {
                            orderedhp_products = orderedhp_products + "|" + item.Product_Id.ToString();
                        }
                    }

                    string orderedpharm_products = string.Empty;
                    foreach (var item in cartProducts.PharmacyProducts)
                    {
                        if (string.IsNullOrEmpty(orderedpharm_products))
                        {
                            orderedpharm_products = item.ProductId.ToString();
                        }
                        else
                        {
                            orderedpharm_products = orderedpharm_products + "|" + item.ProductId.ToString();
                        }
                    }
                    orderpp.orderPlacedHealthProducts   = orderedhp_products;
                    orderpp.orderPlacedPharmacyProducts = orderedpharm_products;
                    db.orderPlacedProducts.Add(orderpp);
                    db.SaveChanges();

                    int orderPlacedId = orderpp.orderPlacedId;

                    Order order = new Order();
                    order.orderdate   = DateTime.Now.Date;
                    order.orderstatus = "In Progress";
                    order.userid      = UserId;
                    order.addressid   = addressId;
                    order.paymenttype = paymentType;
                    if (paymentType == "online")
                    {
                        order.paymentstatus = "complete";
                    }
                    else
                    {
                        order.paymentstatus = "In Progress";
                    }
                    order.totalamount   = cartProducts.TotalPrice;
                    order.orderPlacedId = orderPlacedId;
                    order.totalItems    = cartProducts.TotalItems;
                    db.Orders.Add(order);
                    db.SaveChanges();


                    var cartproducts = db.Carts.Where(i => i.userid == UserId).ToList();
                    foreach (var item in cartproducts)
                    {
                        db.Carts.Remove(item);
                        db.SaveChanges();
                    }
                }
                else
                {
                    orderPlacedProduct orderpp            = new orderPlacedProduct();
                    string             orderedhp_products = string.Empty;
                    foreach (var item in cartProducts.HealthProducts)
                    {
                        if (string.IsNullOrEmpty(orderedhp_products))
                        {
                            orderedhp_products = item.Product_Id.ToString();
                        }
                        else
                        {
                            orderedhp_products = orderedhp_products + "|" + item.Product_Id.ToString();
                        }
                    }

                    string orderedpharm_products = string.Empty;
                    foreach (var item in cartProducts.PharmacyProducts)
                    {
                        if (string.IsNullOrEmpty(orderedpharm_products))
                        {
                            orderedpharm_products = item.ProductId.ToString();
                        }
                        else
                        {
                            orderedpharm_products = orderedpharm_products + "|" + item.ProductId.ToString();
                        }
                    }
                    orderpp.orderPlacedHealthProducts   = orderedhp_products;
                    orderpp.orderPlacedPharmacyProducts = orderedpharm_products;
                    db.orderPlacedProducts.Add(orderpp);
                    db.SaveChanges();

                    int orderPlacedId = orderpp.orderPlacedId;

                    Order order = new Order();
                    order.orderdate   = DateTime.Now.Date;
                    order.orderstatus = "In Progress";
                    order.userid      = UserId;
                    order.addressid   = addressId;
                    order.paymenttype = paymentType;
                    if (paymentType == "online")
                    {
                        order.paymentstatus = "complete";
                    }
                    else
                    {
                        order.paymentstatus = "In Progress";
                    }
                    order.totalamount   = cartProducts.TotalPrice;
                    order.orderPlacedId = orderPlacedId;
                    order.totalItems    = cartProducts.TotalItems;
                    db.Orders.Add(order);
                    db.SaveChanges();
                    var cartproducts = db.Carts.Where(i => i.userid == UserId).ToList();
                    foreach (var item in cartproducts)
                    {
                        db.Carts.Remove(item);
                        db.SaveChanges();
                    }
                    string outputHtml = paymentRequest(order);
                    ViewBag.htmldata = outputHtml;
                    return(View("PaymentPage"));
                }
                return(View("OrderPlaced"));
            }
        }