Ejemplo n.º 1
0
 public Headphones(HeadphonesModel headphonesModel)
 {
     Name               = headphonesModel.Name;
     Price              = headphonesModel.Price;
     IsAvailable        = headphonesModel.IsAvailable;
     Description        = headphonesModel.Description;
     ProducerId         = headphonesModel.ProducerId;
     ManufacturerId     = headphonesModel.ManufacturerId;
     MaterialValue      = headphonesModel.Material;
     ColorValue         = headphonesModel.Color;
     TypeValue          = headphonesModel.Type;
     WirelessTypeValue  = headphonesModel.WirelessType;
     ConnectorTypeValue = headphonesModel.ConnectorType;
     if (headphonesModel.UserId != null && headphonesModel.UserId != new Guid())
     {
         UserId = headphonesModel.UserId;
     }
 }
Ejemplo n.º 2
0
        public async Task <int> AddHeadphones(HeadphonesModel headphonesModel, string email)
        {
            try
            {
                headphonesModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id;
                var headphones = new Headphones(headphonesModel);
                await AddGoodData(headphonesModel.ImageIds, headphones);

                await _context.Headphones.AddAsync(headphones);

                await _context.SaveChangesAsync();

                return(1);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public async Task <int> AddHeadphones([FromBody] HeadphonesModel headphonesModel)
 {
     return(await _goodsCreator.AddHeadphones(headphonesModel, User.Identity.Name));
 }