Exemple #1
0
        public void ShopDtoIsMapped()
        {
            var     shopGuid    = Guid.NewGuid();
            var     addressGuid = new Guid();
            ShopDto shopDto     = new ShopDto()
            {
                Address = new UserAddressDto()
                {
                    AddressGuid    = addressGuid,
                    BuildingNumber = "testBuildingNumber",
                    City           = "Krakow",
                    Email          = "*****@*****.**",
                    PhoneNumber    = "123123123",
                    Street         = "Kapelanka"
                },
                Name     = "testShopName",
                ShopGuid = shopGuid
            };

            Shop shop = shopDto.Map();

            shop.UniqueId.Should().Be(shopGuid);
            shop.Name.Should().Be(shopDto.Name);
            shop.Address.UniqueId.Should().Be(addressGuid);
            shop.Address.BuildingNumber.Should().Be(shopDto.Address.BuildingNumber);
            shop.Address.City.Should().Be(shopDto.Address.City);
            shop.Address.Email.Should().Be(shopDto.Address.Email);
            shop.Address.Street.Should().Be(shopDto.Address.Street);
        }
        public ViewResult EditShop(Guid shopGuid)
        {
            ShopDto shop = _shopRepositoryClient.GetShopByUniqueId(shopGuid);

            if (shop == null)
            {
//                ViewBag.Error = "Shop does not exist";
//                return RedirectToAction("AdminShopList")
            }
            return(View("EditShop", shop.Map()));
        }
Exemple #3
0
        public ServiceActionResult AddNewShop(ShopDto shop)
        {
            if (shop == null)
            {
                return(new ServiceActionResult(ActionStatus.NotSuccessfull, "Shop cannot be null"));
            }
            try
            {
                var checkShop = _shopRepository.GetShopByName(shop.Name);
                if (checkShop != null)
                {
                    return(new ServiceActionResult(ActionStatus.NotSuccessfull, "Shop with the same name already exist"));
                }

                _shopRepository.AddToDatabase(shop.Map());
                return(ServiceActionResult.Successfull);
            }
            catch (Exception ex)
            {
                return(new ServiceActionResult(ActionStatus.WithException, ex));
            }
        }