public VideoCard(VideoCardModel videoCardModel) { Name = videoCardModel.Name; Price = videoCardModel.Price; IsAvailable = videoCardModel.IsAvailable; Description = videoCardModel.Description; ProducerId = videoCardModel.ProducerId; ManufacturerId = videoCardModel.ManufacturerId; MaterialValue = videoCardModel.Material; ColorValue = videoCardModel.Color; VideoSize = videoCardModel.VideoSize; DriveInterfaceValue = videoCardModel.DriveInterface; VideoMemoryCapacity = videoCardModel.VideoMemoryCapacity; if (videoCardModel.UserId != null && videoCardModel.UserId != new Guid()) { UserId = videoCardModel.UserId; } }
public async Task <int> AddVideoCard(VideoCardModel videoCardModel, string email) { try { videoCardModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id; var videoCard = new VideoCard(videoCardModel); await AddGoodData(videoCardModel.ImageIds, videoCard); await _context.VideoCards.AddAsync(videoCard); await _context.SaveChangesAsync(); return(1); } catch (Exception) { throw; } }
public async Task <int> AddVideoCard([FromBody] VideoCardModel videoCardModel) { return(await _goodsCreator.AddVideoCard(videoCardModel, User.Identity.Name)); }