public async Task <ServiceResponseBase> Create(CheckStockViewModel vm, AccountViewModel account) { try { var checkStock = Mapper.Map <CheckStock>(vm); await _context.CheckStock.AddAsync(checkStock); await _context.SaveChangesAsync(); return(new ServiceResponseBase() { Status = Status.ok }); } catch (Exception ex) { _logger.LogError(ex.Message, ex); return(new ServiceResponseBase() { Status = Status.error, Message = ex.Message }); } }
public async Task <ServiceResponseBase> Update(CheckStockViewModel vm, AccountViewModel account) { try { var checkStock = await _context.CheckStock.FirstOrDefaultAsync(o => o.Id == vm.Id); Mapper.Map(vm, checkStock); _context.Entry(checkStock).State = EntityState.Modified; await _context.SaveChangesAsync(); return(new ServiceResponseBase() { Status = Status.ok }); } catch (Exception ex) { _logger.LogError(ex.Message, ex); return(new ServiceResponseBase() { Status = Status.error, Message = ex.Message }); } }