예제 #1
0
        /// <summary>
        /// The AddProduct
        /// </summary>
        /// <param name="name">The name<see cref="string"/></param>
        /// <param name="price">The price<see cref="decimal"/></param>
        /// <returns>The <see cref="string"/></returns>
        public string AddProduct(string name, decimal price)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("userName", "UserName cannot be null, enmpty or only white spaces.");
            }
            if (price <= 0m)
            {
                throw new ArgumentNullException("price", "price cannot be less than 0.");
            }
            var locker = LockFile("product.lk");
            var result = _marketRepository.AddProduct(new Product {
                Name = name, Price = price
            }).ToString();

            UnlockFile(locker);
            return(result);
        }