public Mause(MauseModel mauseModel) { Name = mauseModel.Name; Price = mauseModel.Price; IsAvailable = mauseModel.IsAvailable; Description = mauseModel.Description; ProducerId = mauseModel.ProducerId; ManufacturerId = mauseModel.ManufacturerId; MaterialValue = mauseModel.Material; ColorValue = mauseModel.Color; TypeValue = mauseModel.Type; ButtonsCount = mauseModel.ButtonsCount; if (mauseModel.UserId != null && mauseModel.UserId != new Guid()) { UserId = mauseModel.UserId; } }
public async Task <int> AddMause(MauseModel mauseModel, string email) { try { mauseModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id; var mause = new Mause(mauseModel); await AddGoodData(mauseModel.ImageIds, mause); await _context.Mice.AddAsync(mause); await _context.SaveChangesAsync(); return(1); } catch (Exception) { throw; } }
public async Task <int> AddMause([FromBody] MauseModel mauseModel) { return(await _goodsCreator.AddMause(mauseModel, User.Identity.Name)); }