public void AddPart(PcPart pcPart, string filepath) { using (IDbConnection db = OpenConnection()) { db.Open(); var idTable = new DataTable(); idTable.Columns.Add("Id"); foreach (var id in pcPart.Properties.Select(x => x.Id)) { idTable.Rows.Add(id); } var fileId = filepath == "" ? "" : Guid.NewGuid().ToString(); db.Execute("AddPcPart", new { ID = Guid.NewGuid(), Name = pcPart._Name, Type = pcPart._Type.ToString(), Info = pcPart.Information, Prop = idTable, FileID = fileId, FilePath = filepath }, commandType: CommandType.StoredProcedure); } }
public async Task <IActionResult> AddPart([FromBody] AdminAddPartRequest request) { PcPart pcPart = new PcPart() { Name = request.Name, BrandId = request.BrandId, Model = request.Model, Description = request.Description, SpecificationId = request.SpecificationId, Price = request.Price, Discount = request.Discount, ImagesId = request.ImagesId, DisplayOrder = request.DisplayOrder, CategoryId = request.CategoryId, StockQuantity = request.StockQuantity }; try { var status = await _adminPcPartsService.AddPcPart(pcPart); if (status) { return(Ok(new AdminAddOrDeleteResponse { Message = "Successfully added new Pc part" })); } return(BadRequest("Failed")); } catch (Exception e) { return(StatusCode(422, e)); } }
public async Task <bool> AddPcPart(PcPart pcPart) { await _dataContext.PcParts.AddAsync(pcPart); var status = await _dataContext.SaveChangesAsync(); return(status > 0); }
private IEnumerable <Propertie> GetPropertiesForPcPart(PcPart part) { using (IDbConnection db = OpenConnection()) { db.Open(); var query = $"SELECT pr.Id, pr._Value, pr.Type FROM Properties pr, Part_Prop p WHERE pr.Id = p.PropertieId AND p.PartID = '{part.Id}'"; return(db.Query <Propertie>(query)); } }
public void AddPcPart(List <int> properties, PcPart pcPart, string filepath) { pcPart.Properties = new List <Propertie>(); foreach (int property in properties) { pcPart.Properties.Add(new Propertie(property)); } _pcBuildRepository.AddPart(pcPart, filepath); }
public void TestInitialize() { _logic = PcBuildFactory.CreateTestLogic(); _testPart = new PcPart("Test motherboard", PcPart.PcType.Motherboard, "Dit is een test motherboard", new List <Propertie> { new Propertie(1, "1150", "Motherboard"), new Propertie(3, "TestProp1", "RAM"), new Propertie(4, "TestProp1", "Power"), new Propertie(5, "TestProp1", "Memory") }, "2") { _Path = "testPath" }; _motherboard = new PcPart("Asus MB PRIME X470-PRO", PcPart.PcType.Motherboard, "Dit is een test motherboard", new List <Propertie> { new Propertie(1, "1150", "Motherboard"), new Propertie(3, "TestProp1", "RAM"), new Propertie(4, "TestProp1", "Power"), new Propertie(5, "TestProp1", "Memory") }, "1") { _Path = "testPath" }; _processor1150 = new PcPart("test Processor 1150", PcPart.PcType.Processor, "Dit is een test proseccor met een sockettype: 1150", new List <Propertie> { new Propertie(1, "1150", "Motherboard") }, "1") { _Path = "Test" }; _processor1151 = new PcPart("test Processore 1151", PcPart.PcType.Processor, "Dit is een test proseccor met een sockettype: 1151", new List <Propertie> { new Propertie(2, "1151", "Motherboard") }, "1") { _Path = "Test" }; _website = new Website("Bol.com", "https://www.bol.com/nl/s/computer/zoekresultaten/N/16430/sc/computer_all/index.html?searchtext=", "span,class,promo-price", "a,class,product-title;h1,class,pdp-header__title bol_header"); }
public Build AddBuild(Build build, PcPart pcPart) { switch (pcPart._Type) { case PcPart.PcType.Case: build.Finished = false; build.Case = pcPart.Properties.Find(x => x.Type == "Case").Id; break; case PcPart.PcType.Motherboard: build.Cpu = pcPart.Properties.Find(x => x.Type == "Motherboard").Id; build.RAM = pcPart.Properties.Find(x => x.Type == "RAM").Id; build.Power = pcPart.Properties.Find(x => x.Type == "Power").Id; build.Memory = pcPart.Properties.Find(x => x.Type == "Memory").Id; break; case PcPart.PcType.Power: build.Finished = true; break; } return(build); }
public void AddPart(PcPart pcPart, string filepath) { _pcParts.Add(pcPart); }
public void AddPart(PcPart pcPart, string filepath) => _pcBuildContext.AddPart(pcPart, filepath);