Example #1
0
        public ApiResponse AddPlant(AddPlantRequest 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.PlantNameIsNotUnique(request.Plant.PlantName))
            {
                response.AddMessage("PlantName", new List <string>()
                {
                    "This plant name is in use. Please choose another."
                });
            }
            else
            {
                response.Id = inventoryManager.AddPlant(request);

                if (response.Id == 0)
                {
                    response.AddMessage("DbError", new List <string>()
                    {
                        "There was an error saving this plant."
                    });
                }
            }

            return(response);
        }