public FlashDrive(FlashDriveModel flashDriveModel) { Name = flashDriveModel.Name; Price = flashDriveModel.Price; IsAvailable = flashDriveModel.IsAvailable; Description = flashDriveModel.Description; ProducerId = flashDriveModel.ProducerId; ManufacturerId = flashDriveModel.ManufacturerId; MaterialValue = flashDriveModel.Material; ColorValue = flashDriveModel.Color; Capacity = flashDriveModel.Capacity; USBSpecificationTypeValue = flashDriveModel.USBSpecificationType; if (flashDriveModel.UserId != null && flashDriveModel.UserId != new Guid()) { UserId = flashDriveModel.UserId; } }
public async Task <int> AddFlashDrive(FlashDriveModel flashDriveModel, string email) { try { flashDriveModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id; var flashDrive = new FlashDrive(flashDriveModel); await AddGoodData(flashDriveModel.ImageIds, flashDrive); await _context.FlashDrives.AddAsync(flashDrive); await _context.SaveChangesAsync(); return(1); } catch (Exception) { throw; } }
public async Task <int> AddFlashDrive([FromBody] FlashDriveModel flashDriveModel) { return(await _goodsCreator.AddFlashDrive(flashDriveModel, User.Identity.Name)); }