public ActionResult Login(Customer logcus, Customer editrole)
        {
            if (logcus.CustomerEmail == null || logcus.CustomerPassword == null)
            {
                ModelState.AddModelError("", "Please enter your email and password!!");
            }
            else
            {
                var b = CustomerModel.GetCustomer(logcus.CustomerEmail);
                if (b == null)
                {
                    ModelState.AddModelError("", "Email incorret");
                    return(View());
                }
                else
                {
                    if (b.CustomerEmail == logcus.CustomerEmail && b.CustomerPassword == logcus.CustomerPassword)
                    {
                        DateTime dateregis = Convert.ToDateTime(b.DateRegister);

                        if (b.CustomerRole == 1)
                        {
                            DateTime datenew     = dateregis.AddMonths(1);
                            DateTime datenow     = DateTime.Today;
                            int      comparedate = DateTime.Compare(datenow, datenew);
                            if (comparedate > 0)
                            {
                                editrole.CustomerEmail = logcus.CustomerEmail;
                                editrole.CustomerRole  = 0;
                                b.CustomerRole         = 0;
                                CustomerModel.editrole(editrole);
                            }
                        }
                        if (b.CustomerRole == 2)
                        {
                            DateTime datenew     = dateregis.AddYears(1);
                            DateTime datenow     = DateTime.Today;
                            int      comparedate = DateTime.Compare(datenow, datenew);
                            if (comparedate > 0)
                            {
                                editrole.CustomerEmail = logcus.CustomerEmail;
                                editrole.CustomerRole  = 0;
                                b.CustomerRole         = 0;
                                CustomerModel.editrole(editrole);
                            }
                        }
                        Session["email"]    = b.CustomerEmail;
                        Session["password"] = b.CustomerPassword;
                        Session["role"]     = b.CustomerRole;
                        Session["id"]       = b.CustomerId;
                        return(RedirectToAction("Book", "Product"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "login fall");
                    }
                }
            }
            return(View());
        }
Beispiel #2
0
 public IActionResult Create(int?id)
 {
     if (id != null)
     {
         CustomerModel customerObj = new CustomerModel();
         ViewBag.Customer = customerObj.GetCustomer(id);
     }
     return(View());
 }
 public ActionResult Profiles(string email)
 {
     if (Session["email"] != null)
     {
         email = Session["email"].ToString();
         return(View(CustomerModel.GetCustomer(email)));
     }
     return(RedirectToAction("Login"));
 }
Beispiel #4
0
        public async Task <IActionResult> GetCustomer(string id)
        {
            var res = await CustomerModel.GetCustomer(id);

            res.RootHref = Url.Link(nameof(GetCustomers), null);
            if (res.Success)
            {
                return(Ok(res));
            }
            return(NotFound());
        }
Beispiel #5
0
 public PartialViewResult Shipping()
 {
     if (Session["email"] != null)
     {
         var user  = Session["email"].ToString();
         var model = CustomerModel.GetCustomer(user);
         if (model != null)
         {
             return(PartialView(model));
         }
     }
     return(PartialView());
 }