Пример #1
0
        public ActionResult Buy(int id)
        {
            string mail    = HttpContext.User.Identity.Name;
            int    buyerId = unit.GetBuyer(mail).Id;

            if (buyerId == unit.GetCar(id).OwnerId)
            {
                ViewBag.Message = "Ты её продаешь дурачек)";
                return(View());
            }
            AppBuyCar b = new AppBuyCar {
                BuyerId = buyerId, CarId = id
            };
            bool   result = unit.Buy(b.FromAppCarToDomainBuyCar());
            string message;

            if (result == true)
            {
                message = "Благодарим за покупку";
            }
            else
            {
                message = "Вы уже отметили";
            }
            ViewBag.Message = message;
            return(View());
        }
Пример #2
0
 public static DomainBuyCar FromAppCarToDomainBuyCar(this AppBuyCar item)
 {
     return(new DomainBuyCar
     {
         CarId = item.CarId,
         BuyerId = item.BuyerId
     });
 }