コード例 #1
0
 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;
     }
 }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
 public async Task <int> AddFlashDrive([FromBody] FlashDriveModel flashDriveModel)
 {
     return(await _goodsCreator.AddFlashDrive(flashDriveModel, User.Identity.Name));
 }