Пример #1
0
        private string[] ExecCreateShop(string args)
        {
            Regex regex = new Regex(@".*create-shop\s+?shop-id='(\d+?)';\s*shop-name='(.+?)';\s*shop-address='(.+?)'\s*");

            if (!regex.IsMatch(args))
            {
                return(new [] { "Err. Incorrect shop data" });
            }

            var    matcher     = regex.Match(args);
            int    shopId      = int.Parse(matcher.Groups[1].Value);
            string shopName    = matcher.Groups[2].Value;
            string shopAddress = matcher.Groups[3].Value;

            try
            {
                _dao.CreateShop(shopId, shopName, shopAddress);
            }
            catch (MissingDataConsistencyException)
            {
                return(new[] { $"Err. Creation error: shop on ID={shopId} already exists" });
            }

            return(new[] { "Creation successful, shop:", $"({shopId}, {shopName}, {shopAddress})" });
        }