コード例 #1
0
        public void GetDetailsById_Returns_BikeDetailsDto()
        {
            var details = new BikeDetails();
            var dto     = new BikeDetailsDto();

            mockRepo.Setup(r => r.GetDetailsById(It.IsAny <Guid>()))
            .Returns(details);

            mockMapper.Setup(m => m.Map <BikeDetailsDto>(details))
            .Returns(dto);

            BikeDetailsDto actual = bikeService.GetDetailsById(Guid.NewGuid());

            Assert.AreEqual(dto, actual);
        }
コード例 #2
0
        public ActionResult CreateAd()
        {
            var            id = Session["ID"];
            List <Bicycle> b  = client.GetBikesByUser(Convert.ToInt32(id));

            List <SelectListItem> Bicycles = new List <SelectListItem>();

            foreach (var VARIABLE in b)
            {
                Bicycles.Add(new SelectListItem {
                    Text = VARIABLE.Year, Value = VARIABLE.ID.ToString()
                });
            }

            BikeDetails ddBikes = new BikeDetails {
                Bicycles = Bicycles
            };

            return(View(ddBikes));
        }
コード例 #3
0
        public ActionResult CreateAd(string inputTitle, string inputDesc, string inputPrice, DateTime?inputSDate, DateTime?inputEDate, BikeDetails ddBike)
        {
            var selectedBike = ddBike.SelectedBike.ID;
            var id           = Session["ID"];

            try
            {
                client.CreateAd(inputTitle, inputDesc, Convert.ToDouble(inputPrice), Convert.ToDateTime(inputSDate), Convert.ToDateTime(inputEDate), selectedBike, Convert.ToInt32(id));
                return(RedirectToAction("Index", "Ads"));
            }
            catch (Exception e)
            {
                TempData["AlertMessage"] = e.Message;
                return(RedirectToAction("Index", "Ads"));
            }
        }