public static void Main(string[] args) { var controller = new WoodFurnitureController(); var model = new CreateWoodFurnitureOrderPostModel { FullName = "Petr Petrov", PhoneNumber = "+380951111133", Date = DateTime.UtcNow.ToString("dd.MM.yyyy"), FurnitureType = "Chair", Color = "Blue", WoodType = "Oak" }; controller.CreateWoodFurnitureRequest(model); var createWoodFurnitureViewModel = controller.GetItemById(0); var model2 = new CreateWoodFurnitureOrderPostModel { FullName = "Petr Petrov", PhoneNumber = "+380951111166", Date = DateTime.UtcNow.ToString("dd.MM.yyyy"), FurnitureType = "Chair", Color = "Blue", WoodType = "Oak" }; controller.CreateWoodFurnitureRequest(model2); var AllItems = controller.GetAll(); }
public void CreateWoodFurnitureRequest(CreateWoodFurnitureOrderPostModel model) { DateTime date; if (!DateTime.TryParseExact(model.Date, new[] { "yyyy-MM-dd", "MM/dd/yy", "dd-MMM-yy", "dd.MM.yyyy" }, null, DateTimeStyles.None, out date)) { throw new System.Exception("Invalid date format"); } var woodFurnitureModel = _mapper.Map <WoodFurnitureOrderModel>(model); _woodWorkshopService.CreateFurnitureRequest(woodFurnitureModel); }
public void CreateWoodFurnitureRequest(CreateWoodFurnitureOrderPostModel model) { if (string.IsNullOrWhiteSpace(model.FullName)) { throw new System.Exception("Invalid FullName"); } if (model.PhoneNumber.Length != 13) { throw new System.Exception("Invalid Phone Number"); } if (model.FurnitureType.Length == 0) { throw new System.Exception("Invalid Furniture Type"); } var woodFurnitureModel = _mapper.Map <WoodFurnitureOrderModel>(model); _woodWorkshopService.CreateFurnitureRequest(woodFurnitureModel); }
static void Main(string[] args) { var controllerWoodFurnitureOrder = new WoodFurnitureOrderController(); var controllerFurnitureType = new FurnitureTypeController(); var controllerWoodType = new WoodTypeController(); var controllerCustomer = new CustomerController(); var controllerEpoxy = new EpoxyController(); var furnitureType = new FurnitureTypePostModel { Name = "Chair", Size = "50x40x45", Varnish = true }; try { controllerFurnitureType.CreateWoodFurnitureRequest(furnitureType); } catch (Exception ex) { Console.WriteLine(ex.Message); } var woodType = new WoodTypePostModel { TypeName = "Acacia", BoardThickness = 10, Price = "50" }; try { controllerWoodType.CreateWoodFurnitureRequest(woodType); } catch (Exception ex) { Console.WriteLine(ex.Message); } var customer = new CustomerPostModel { FullName = "Petr Petrov", PhoneNumber = "+380951111166" }; try { controllerCustomer.CreateWoodFurnitureRequest(customer); } catch (Exception ex) { Console.WriteLine(ex.Message); } var epoxy = new EpoxyPostModel { Type = "Jewelry", Price = "80" }; try { controllerEpoxy.CreateWoodFurnitureRequest(epoxy); } catch (Exception ex) { Console.WriteLine(ex.Message); } var modelWoodFurnitureOrder = new CreateWoodFurnitureOrderPostModel { Date = DateTime.UtcNow.ToString("dd.MM.yyyy"), FurnitureTypeId = 1, Color = "Blue", WoodTypeId = 3, FurnitureType = furnitureType, WoodType = woodType, Customer = customer, Epoxy = epoxy }; controllerWoodFurnitureOrder.CreateWoodFurnitureRequest(modelWoodFurnitureOrder); var createWoodFurnitureViewModel = controllerWoodFurnitureOrder.GetItemById(0); var AllItems = controllerWoodFurnitureOrder.GetAll(); }