Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves a customer details and renders a view on the screen.
        /// </summary>
        /// <returns>Renders a view on screen.</returns>
        public ActionResult Index()
        {
            Customer customer = null;

            if (!string.IsNullOrEmpty(Request.QueryString["c"]))
            {
                int customerId;
                var isInteger = Int32.TryParse(Request.QueryString["c"], out customerId);
                if (isInteger)
                {
                    var command = new GetCustomerDataCommand(customerId);
                    customer       = command.Execute();
                    ViewBag.UserId = customerId.ToString();
                }
            }
            ViewBag.FirstName = customer != null ? customer.FirstName : "";
            return(View());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Renders a view on screen.
        /// </summary>
        /// <returns>A view</returns>
        public ActionResult Index()
        {
            var    customerId = String.Empty;
            string modelCode;

            var viewModel = new FormViewModel();

            if (!String.IsNullOrEmpty(Request.QueryString["c"]))
            {
                customerId = Request.QueryString["c"];

                var command  = new GetCustomerDataCommand(Int32.Parse(customerId));
                var customer = command.Execute();
                viewModel = new FormViewModel
                {
                    FirstName = customer.FirstName.ToLower().ToTitleCase(),
                    LastName  = customer.LastName.ToLower().ToTitleCase(),
                    Email     = customer.Email.ToLower()
                };
            }
            if (!String.IsNullOrEmpty(Request.QueryString["m"]))
            {
                modelCode = Request.QueryString["m"];
            }
            else
            {
                var cQuery = customerId != String.Empty ? ("?c=" + customerId) : "";
                return(RedirectToAction("Index", "Home", cQuery));
            }

            var result = new List <Title>();
            var values = Enum.GetValues(typeof(Salutation));

            foreach (var item in values)
            {
                result.Add(new Title {
                    Id = (int)item, Name = item.ToString()
                });
            }

            viewModel.Titles = result.ToList();
            viewModel.Code   = modelCode;

            var car = _dbContext.GetCar(modelCode).SingleOrDefault();

            if (car != null)
            {
                ViewBag.ModelName = car.Name;
            }
            ViewBag.UserId     = customerId;
            ViewBag.ModelCode  = modelCode;
            ViewBag.EngineName = car.EngineName;
            ViewBag.Brand      = car.Brand;
            ViewBag.Url        = car.Url;
            ViewBag.ModelName  = car.Name;
            ViewBag.Model      = car.Model;

            if (!string.IsNullOrEmpty(customerId))
            {
                viewModel.UserId = Int32.Parse(customerId);
            }
            return(View(viewModel));
        }