Esempio n. 1
0
        public ActionResult Login(Customer customer)
        {
            using (var context = new SuncityDatabase())
            {
                Customer usr = context.Customers.SingleOrDefault(record => record.Email == customer.Email && record.Password == customer.Password);

                if (usr != null)
                {
                    Session["UserId"]    = usr.CustomerId.ToString();
                    Session["Email"]     = usr.Email.ToString();
                    Session["FirstName"] = usr.FirstName.ToString();

                    if (Session["Email"].ToString() == "*****@*****.**")
                    {
                        return(RedirectToAction("CustomerRecord"));
                    }
                    else
                    {
                        return(RedirectToAction("index", "home"));
                    }
                }

                else
                {
                    ModelState.AddModelError("", "Invalid Email or Password");
                }
            }//End Using

            return(View());
        }
Esempio n. 2
0
        ActionResult AgentLogin(Agent agent)
        {
            using (var context = new SuncityDatabase())
            {
                Agent usr = context.Agents.SingleOrDefault(record => record.Email == agent.Email && record.Password == agent.Password);

                if (usr != null)
                {
                    Session["UserId"]    = usr.AgentId.ToString();
                    Session["Email"]     = usr.Email.ToString();
                    Session["FirstName"] = usr.FirstName.ToString();

                    if (Session["Email"].ToString() == "*****@*****.**")
                    {
                        return(RedirectToAction("AgentRecord"));
                    }
                    else
                    {
                        return(RedirectToAction("AgentProfile"));
                    }
                }

                else
                {
                    ModelState.AddModelError("", "Invalid Email or Password");
                }
            }//End Using
            return(View());
        }
Esempio n. 3
0
        public ActionResult Registration(Customer customer)
        {
            ViewBag.Title = "Register";

            if (ModelState.IsValid)
            {
                using (var context = new SuncityDatabase())
                {
                    Customer usr = context.Customers.FirstOrDefault(record => record.Email == customer.Email);
                    if (usr != null)
                    {
                        ViewBag.error = usr.Email + " account already exist";
                        return(View());
                    }

                    else
                    {
                        customer.DateRegistered = DateTime.Now;
                        context.Customers.Add(customer);
                        context.SaveChanges();
                        ViewBag.Registered = "Succeccfully Registered";
                        ModelState.Clear();
                    }
                }
            }
            return(View());
        }
Esempio n. 4
0
        public ActionResult EditCustomer(Customer customer)
        {
            using (var context = new SuncityDatabase())
            {
                if (customer.CustomerId > 0)
                {
                    var val = context.Customers.Where(record => record.CustomerId == customer.CustomerId).FirstOrDefault();

                    if (val != null)
                    {
                        val.FirstName       = customer.FirstName;
                        val.LastName        = customer.LastName;
                        val.Email           = customer.Email;
                        val.PhoneNumber     = customer.PhoneNumber;
                        val.Password        = customer.Password;
                        val.ConfirmPassword = customer.ConfirmPassword;
                    }
                }
                else
                {
                    context.Customers.Add(customer);
                }
                context.SaveChanges();
                return(RedirectToAction("EmployeeRecord"));
            }
        }
Esempio n. 5
0
        public ActionResult AgentRecord()
        {
            ViewBag.title = "Customer Record";

            using (var context = new SuncityDatabase())
            {
                var agents = (from row in context.Agents orderby row.AgentId descending select row).ToList();
                return(View(agents));
            }
        }
Esempio n. 6
0
        public ActionResult CustomerRecord()
        {
            ViewBag.title = "Customer Record";

            using (var context = new SuncityDatabase())
            {
                var customers = (from row in context.Customers orderby row.DateRegistered descending select row).ToList();
                return(View(customers));
            }
        }
Esempio n. 7
0
 public ActionResult EditCustomer(int?id)
 {
     if (id == null)
     {
         return(HttpNotFound());
     }
     using (var context = new SuncityDatabase())
     {
         Customer customer = context.Customers.Single(row => row.CustomerId == id);
         return(View(customer));
     }
 }
Esempio n. 8
0
        public ActionResult ConfirmDeleteCustomer(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            using (var context = new SuncityDatabase())
            {
                Customer customer = context.Customers.Single(row => row.CustomerId == id);
                context.Customers.Remove(customer);
                context.SaveChanges();

                return(RedirectToAction("CustomerRecord"));
            }
        }
Esempio n. 9
0
        public ActionResult AgentProfile()
        {
            if (Session["id"] != null)
            {
                using (var context = new SuncityDatabase())
                {
                    string user_Id = Session["id"].ToString();
                    var    user    = context.Agents.Single(row => row.AgentId.ToString() == user_Id);

                    return(View(user));
                }
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
Esempio n. 10
0
        public ActionResult AgentRegistration(Agent agent)
        {
            if (ModelState.IsValid)
            {
                using (var Context = new SuncityDatabase())
                {
                    Agent usr = Context.Agents.FirstOrDefault(record => record.Email == agent.Email);
                    if (usr != null)
                    {
                        ViewBag.error = usr.Email + " account already exist";
                    }
                    else
                    {
                        Context.Agents.Add(agent);
                        Context.SaveChanges();
                        ViewBag.alert = "Successfully Registered Check your mail for further information";
                        ModelState.Clear();
                    }
                }
            }

            return(View());
        }