Пример #1
0
 public Cooler(CoolerModel coolerModel)
 {
     Name           = coolerModel.Name;
     Price          = coolerModel.Price;
     IsAvailable    = coolerModel.IsAvailable;
     Description    = coolerModel.Description;
     ProducerId     = coolerModel.ProducerId;
     ManufacturerId = coolerModel.ManufacturerId;
     MaterialValue  = coolerModel.Material;
     ColorValue     = coolerModel.Color;
     TypeValue      = coolerModel.Type;
     FanSize        = coolerModel.FanSize;
     if (coolerModel.UserId != null && coolerModel.UserId != new Guid())
     {
         UserId = coolerModel.UserId;
     }
 }
Пример #2
0
        public async Task <int> AddCooler(CoolerModel coolerModel, string email)
        {
            try
            {
                coolerModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id;
                var cooler = new Cooler(coolerModel);
                await AddGoodData(coolerModel.ImageIds, cooler);

                await _context.Coolers.AddAsync(cooler);

                await _context.SaveChangesAsync();

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