コード例 #1
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));
            }
        }