/* GET: Customer/Details/5
         * public ActionResult Details(int id)
         * {
         *  return View();
         * }
         */
        // GET: Customer/Create
        public ActionResult Create()
        {
            bool   customerExist;
            string userId;
            string userEmail = User.Identity.Name;
            string returnUrl = Url.Content("~/Customer/Index");

            if (userEmail != null)
            {
                //var customer = new CustomerBL();
                ApplicationUserBL appUser = new ApplicationUserBL();
                userId = appUser.GetUserId(userEmail);

                customerExist = _custBl.ExistCustomer(userId);
                if (!customerExist)
                {
                    ViewBag.AppUserId = userId;
                    return(View());
                }
                else
                {
                    return(LocalRedirect(returnUrl));
                }
            }
            else
            {
                return(LocalRedirect(returnUrl));
            }
        }
Beispiel #2
0
        private int FindCustId(string userEmail)
        {
            ApplicationUserBL appUser = new ApplicationUserBL();
            string            userId  = appUser.GetUserId(userEmail);
            int custId = _custBl.GetCustId(userId);

            ViewBag.Fullname = _custBl.GetCustFullName(userId);
            return(custId);
        }
        // GET: Customer
        public ActionResult Index()
        {
            bool   customerExist = false;
            string userEmail     = User.Identity.Name;

            if (userEmail != null)
            {
                ApplicationUserBL appUser = new ApplicationUserBL();
                string            userId  = appUser.GetUserId(userEmail);
                customerExist = _custBl.ExistCustomer(userId);
                if (customerExist)
                {
                    ViewBag.Fullname = _custBl.GetCustFullName(userId);
                }
            }
            ViewBag.ExistCust = customerExist;
            return(View());
        }
        // GET: Customer/Edit/5
        public ActionResult Edit()
        {
            bool   customerExist;
            string userId;
            string userEmail = User.Identity.Name;
            string returnUrl = Url.Content("~/Customer/Index");

            if (userEmail != null)
            {
                //var customer = new CustomerBL();
                ApplicationUserBL appUser = new ApplicationUserBL();
                userId = appUser.GetUserId(userEmail);

                customerExist = _custBl.ExistCustomer(userId);
                if (customerExist)
                {
                    var customer = _custBl.GetCustomer(_custBl.GetCustId(userId));
                    return(View(customer));
                }
            }
            return(LocalRedirect(returnUrl));
            //return View(customer);*/
        }