예제 #1
0
        public ApiResponse AddArrangement(AddArrangementRequest 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.ArrangementNameIsnotUnique(request.Arrangement))
            {
                response.AddMessage("ArrangementName", new List <string>()
                {
                    "This arrangement name is in use. Please choose another."
                });
            }
            else
            {
                long arrangement_id = inventoryManager.AddArrangement(request);
                if (arrangement_id == 0)
                {
                    response.AddMessage("DbError", new List <string>()
                    {
                        "There was an error saving this arrangement."
                    });
                }
                else
                {
                    response.Id = arrangement_id;
                }
            }

            return(response);
        }