예제 #1
0
        public ApiResponse AddContainer(AddContainerRequest request)
        {
            ApiResponse response = new ApiResponse();

            if (inventoryManager.InventoryNameIsNotUnique(request.Inventory.InventoryName))
            {
                response.AddMessage("InventoryName", new List <string>()
                {
                    "This inventory name is in use. Please choose another."
                });
            }
            else if (inventoryManager.ContainerNameIsNotUnique(request.Container.ContainerName))
            {
                response.AddMessage("ContainerName", new List <string>()
                {
                    "This container name is in use. Please choose another."
                });
            }
            else
            {
                response.Id = inventoryManager.AddContainer(request);
                if (response.Id == 0)
                {
                    response.AddMessage("DbError", new List <string>()
                    {
                        "There was an error saving this container."
                    });
                }
            }

            return(response);
        }