예제 #1
0
 public ComputerPart(ComputerPartModel computerPartModel)
 {
     Name           = computerPartModel.Name;
     Price          = computerPartModel.Price;
     IsAvailable    = computerPartModel.IsAvailable;
     Description    = computerPartModel.Description;
     ProducerId     = computerPartModel.ProducerId;
     ManufacturerId = computerPartModel.ManufacturerId;
     MaterialValue  = computerPartModel.Material;
     ColorValue     = computerPartModel.Color;
     if (computerPartModel.UserId != null && computerPartModel.UserId != new Guid())
     {
         UserId = computerPartModel.UserId;
     }
 }
예제 #2
0
        public async Task <int> AddComputerPart(ComputerPartModel computerPartModel, string email)
        {
            try
            {
                computerPartModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id;
                var computerPart = new ComputerPart(computerPartModel);
                await AddGoodData(computerPartModel.ImageIds, computerPart);

                await _context.ComputerParts.AddAsync(computerPart);

                await _context.SaveChangesAsync();

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