예제 #1
0
        public string ConfirmOrder(string UserID)
        {
            DetailsViewModel custDetails = new DetailsViewModel();
            custDetails = (DetailsViewModel)Session["MyOrder"];
            List<CartItem> cart = (List<CartItem>)Session["cart"];

            List<MyOrder> orders = new List<MyOrder>();

            for (int i = 0; i < cart.Count; i++)
            {
                MyOrder order = new MyOrder();
                order.ShippingAddress = custDetails.Address;
                order.City = custDetails.City;
                order.State = custDetails.State;
                order.Pincode = custDetails.Pincode;
                order.UserID = UserID;
                order.ApparelID = cart[i].Apparel.ApparelID;
                order.ProductName = cart[i].Apparel.ApparelName;
                order.SizeOfApparel = cart[i].Apparel.ApparelSize;
                order.Quantity = cart[i].Quantity;
                order.TotalAmount = cart[i].Quantity * (cart[i].Apparel.ApparelCost - (cart[i].Apparel.ApparelCost * cart[i].Apparel.ApparelDiscount)/100);
                orders.Add(order);
            }
            string status = bllObj.InsertOrderDetails(orders);
            if (!status.Equals("false"))
                Session["cart"] = null;
            return status;
        }
예제 #2
0
        public bool CheckAndUpdateCustomer(DetailsViewModel model,out int statusCode)
        {
            bool status = false;
            string conStr = ConfigurationManager.ConnectionStrings["FashionableMeDB"].ConnectionString;
            SqlConnection conn = new SqlConnection(conStr);
            SqlCommand cmd;
            statusCode = 0;
            string userID = HttpContext.Current.Session["UserID"].ToString();
            try
            {
                conn.Open();
                if (model.OldPassword != "")
                {
                    cmd = new SqlCommand("UPDATE Customer SET Password=@newPass where UserID=@userid and Password=@pass ", conn);
                    cmd.Parameters.AddWithValue("newPass", model.Password);
                    cmd.Parameters.AddWithValue("userid", userID);
                    cmd.Parameters.AddWithValue("pass", model.OldPassword);

                    int count = (Int32)cmd.ExecuteNonQuery() ;
                    if (count == 0)
                    {
                        HttpContext.Current.Session["ErrorMessage"] = "Old Password is NOT Correct ";
                        statusCode = 1;
                        status = false;
                    }
                    else
                    {
                        status = true;
                    }
                }
                else
                {
                    cmd = new SqlCommand("UPDATE Customer SET Name=@name , Address=@address , City=@city , State=@state , Pincode=@pincode , MobileNumber=@mobile , Gender=@gender where  UserID=@userID   ",conn);
                    cmd.Parameters.AddWithValue("name",model.Name);
                    cmd.Parameters.AddWithValue("address",model.Address);
                    cmd.Parameters.AddWithValue("city",model.City);
                    cmd.Parameters.AddWithValue("state",model.State);
                    cmd.Parameters.AddWithValue("pincode", model.Pincode);
                    cmd.Parameters.AddWithValue("mobile",model.MobileNumber);
                    cmd.Parameters.AddWithValue("gender",model.IsMale?"M":"F");
                    cmd.Parameters.AddWithValue("userID",userID);
                    int success = cmd.ExecuteNonQuery();
                    if (success > 0)
                    {
                        status = true;
                        statusCode = 0;
                    }
                }

            }
            catch (Exception Exc)
            {
                HttpContext.Current.Session["ErrorMessage"] = Exc.Message;
                statusCode = 2;
            }

            conn.Close();
            return status;
        }
예제 #3
0
        public string CheckAndUpdateCustomer(DetailsViewModel model,out int statusCode)
        {
            string status = "";
            model.OldPassword = model.OldPassword ?? "" ;
            if (model.OldPassword != "" )
            {
                model.OldPassword = hashPassword(model.OldPassword);
                model.Password = hashPassword(model.Password);
            }

            CustomerDal dalObj = new CustomerDal();
            statusCode = 0;
            if (dalObj.CheckAndUpdateCustomer(model,out statusCode))
                status = "Updated Successfully";
            else
                status = HttpContext.Current.Session["ErrorMessage"].ToString();

            return status;
        }
예제 #4
0
        public DetailsViewModel GetCustomerDetails(string userID)
        {
            DetailsViewModel custObj = null;
            string conStr = ConfigurationManager.ConnectionStrings["FashionableMeDB"].ConnectionString;
            SqlConnection conn = new SqlConnection(conStr);
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand("SELECT * FROM Customer WHERE  UserID=@user ",conn);
                cmd.Parameters.AddWithValue("user",userID);
                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    custObj = new DetailsViewModel();
                    custObj.Name = reader.GetString(reader.GetOrdinal("Name"));
                    custObj.Address = reader.GetString(reader.GetOrdinal("Address"));
                    custObj.City = reader.GetString(reader.GetOrdinal("City"));
                    custObj.State = reader.GetString(reader.GetOrdinal("State"));
                    custObj.Pincode = reader.GetString(reader.GetOrdinal("Pincode"));
                    custObj.MobileNumber = reader.GetString(reader.GetOrdinal("MobileNumber"));
                    custObj.IsMale = (reader.GetString(reader.GetOrdinal("Gender"))=="M")?true:false;
                }
            }
            catch (Exception exc)
            {
                HttpContext.Current.Session["ErrorMessage"] = exc.Message;
            }

            return custObj;
        }
예제 #5
0
        public ActionResult Shipping(DetailsViewModel custDetails)
        {
            if (Session["UserID"] == null)
                return RedirectToAction("Login", "Account");
            if (Session["UserRole"].ToString() == "admin")
                return RedirectToAction("Index", "Admin");

            ViewBag.UserID = Session["UserID"];
            Session["MyOrder"] = custDetails;
            return View("CheckOut", custDetails);
        }
예제 #6
0
        public ActionResult Shipping()
        {
            if (Session["UserID"] == null)
                return RedirectToAction("Login", "Account");

            if (Session["UserRole"].ToString() == "admin")
                return RedirectToAction("Index", "Admin");

            List<CartItem> cart = (List<CartItem>)Session["cart"];
            if (Session["cart"]==null || cart.Count<1)
            {
                return RedirectToAction("Index");
            }

            bool isUpdated = VerifyQuantity();

            bool isZero = RemoveZeroQuantity();
            if (isUpdated || isZero)
                return RedirectToAction("Index");

            DetailsViewModel custDetails = new DetailsViewModel();

            if (Session["UserID"] != null)

            {

                custDetails = bllObj.getShippingDetails(Session["UserID"].ToString());

            }

            return View(custDetails);
        }