Exemple #1
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"));
            }
        }
Exemple #2
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());
        }
Exemple #3
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"));
            }
        }
Exemple #4
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());
        }