Ejemplo n.º 1
0
        public ActionResult Enquire(EnquiryViewModel enquiryInfo)
        {
            _logger.Information("Starting to enquire with {0}", JsonConvert.SerializeObject(enquiryInfo));
            if (ModelState.IsValid && _carManager.FindById(enquiryInfo.CarId) != null)
            {
                var enquiry = Mapper.Map <Enquiry>(enquiryInfo);
                _enquiryManager.Enquire(enquiry);

                _logger.Information("Enquiring successful: enquiry {0}", JsonConvert.SerializeObject(enquiry));
                return(View("Success"));
            }
            else
            {
                _logger.Error("Enquiring failed with invalid enquiry input {0}", JsonConvert.SerializeObject(enquiryInfo));
                return(View("Failed"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Comment(CommentViewModel commentInfo)
        {
            _logger.Information("Starting to comment with {0}", JsonConvert.SerializeObject(commentInfo));
            if (ModelState.IsValid && _carManager.FindById(commentInfo.CarId) != null)
            {
                var comment = Mapper.Map <Comment>(commentInfo);//<Comment>(commentInfo);
                _commentManager.Comment(comment);

                _logger.Information("Commenting successful: comment {0}", JsonConvert.SerializeObject(comment));
                return(View("Success"));
            }
            else
            {
                _logger.Error("Commenting failed with invalid comment input {0}", JsonConvert.SerializeObject(commentInfo));
                return(View("Failed"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Details(int?id = null)
        {
            if (!id.HasValue)
            {
                _logger.Warning("Details was called with no Id, redirecting to home");
                return(Redirect("/Home/Index"));
            }

            var car = _carManager.FindById(id.Value);

            if (car == null)
            {
                _logger.Error("Car by Id {0} does not exist, redirecting to home", id.Value);
                return(Redirect("/Home/Index"));
            }

            var carViewModel = Mapper.Map <CarViewModel>(car);

            return(View(carViewModel));
        }