public CPU(CPUModel cpuModel) { Name = cpuModel.Name; Price = cpuModel.Price; IsAvailable = cpuModel.IsAvailable; Description = cpuModel.Description; ProducerId = cpuModel.ProducerId; ManufacturerId = cpuModel.ManufacturerId; MaterialValue = cpuModel.Material; ColorValue = cpuModel.Color; CPUSocketTypeValue = cpuModel.CPUSocketType; ThermalDesignPower = cpuModel.ThermalDesignPower; NumberOfCores = cpuModel.NumberOfCores; NumberOfThreads = cpuModel.NumberOfThreads; if (cpuModel.UserId != null && cpuModel.UserId != new Guid()) { UserId = cpuModel.UserId; } }
public async Task <int> AddCPU(CPUModel cpuModel, string email) { try { cpuModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id; var cpu = new CPU(cpuModel); await AddGoodData(cpuModel.ImageIds, cpu); await _context.CPUs.AddAsync(cpu); await _context.SaveChangesAsync(); return(1); } catch (Exception) { throw; } }
public async Task <int> AddCPU([FromBody] CPUModel cpuModel) { return(await _goodsCreator.AddCPU(cpuModel, User.Identity.Name)); }