public string Test()
        {
            StringBuilder result  = new StringBuilder();
            Product       product = new Product(0)
            {
                CLIN                     = "clin001",
                UNSPSC                   = "unspsc01",
                Description              = "This is a long description. Parts of it will be extracted to be used as the title. This is done by a person, not by the system.",
                UnitOfMeasure            = "EACH",
                QuantityPerUnitOfMeasure = "UnitOfMeasure",
                ContractDiscount         = "50%",
                ContractNumber           = "Contract111222",
                Contractor               = "Contractor A",
                ContractExpiration       = DateTime.Now.AddYears(1),
                Title                    = "This is a long description.",
                ListPrice                = 150.0m,
                ContractPrice            = 100.0m,
                Manufacturer             = "mfg 1",
                ManufacturerPartNumber   = "mpn 1",
                SKU         = "sku 1",
                ProductType = ProductType.Hardware.ToString(),
                Category    = "Category 1",
            };

            try
            {
                result.AppendLine("Beginning test");
                result.AppendLine(string.Format("Have {0} row(s)", inventoryService.Fetch(0, int.MaxValue, null).Count()));
                inventoryService.Add(product);
                result.AppendLine("Added product: " + product.Id);
                result.AppendLine(string.Format("Have {0} row(s)", inventoryService.Fetch(0, int.MaxValue, null).Count()));
                product.Title += " - updated";
                inventoryService.Update(product);
                result.AppendLine("Updated product: " + product.Id);
                inventoryService.Delete(product.Id);
                result.AppendLine("Deleted product: " + product.Id);
                result.AppendLine(string.Format("Have {0} row(s)", inventoryService.Fetch(0, int.MaxValue, null).Count()));
                result.AppendLine("test success: " + product.Id.ToString());
                return(result.ToString());
            }
            catch (Exception x)
            {
                return(x.Message);
            }
        }
        public async Task <IActionResult> Add(InventoryDTO inventory)
        {
            var result = await _inventoryService.Add(inventory);

            if (!result.IsSucceeded)
            {
                return(BadRequest(result.GetErrorString()));
            }
            return(Ok(result.Value));
        }
Exemplo n.º 3
0
 public Response Post(DeliveryDto model)
 {
     if (ModelState.IsValid)
     {
         return(_inventoryService.Add(model));
     }
     return(new Response
     {
         IsSuccess = false,
         Errors = new Error("", "اطلاعات ورودی صحیح نمی باشد"),
     });
 }
        public ActionResult Create(InventoryEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.Inventory.Updated = DateTime.Now;
            model.Inventory.ByUser  = User.Identity.Name;
            _service.Add(model.Inventory);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
 public IActionResult Post(Inventory inventory)
 {
     try
     {
         int result = _inventoryService.Add(inventory);
         if (result == 1)
         {
             return(StatusCode(201, inventory));
         }
         else
         {
             return(StatusCode(404, "veri kaydedilemedi."));
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(404, ex));
     }
 }
Exemplo n.º 6
0
        public ActionResult Add(InventoryModel inventoryModel)

        {
            return(Ok(_inventoryService.Add(inventoryModel)));
        }