public async Task <Result> InsertChangeLog(ChangeLog model) { var validator = new ChangeLogValidator(true); var result = validator.Validate(model).GetResult(); if (!result.Success) { return(result); } var entity = MapCompanyModelToEntity(model); await _context.ChangeLog.AddAsync(entity); await _context.SaveChangesAsync(); model.Id = entity.Id; result.Tag = model; return(result); }
public async Task <Result> UpdateChangeLog(ChangeLog model) { var validator = new ChangeLogValidator(false); var result = validator.Validate(model).GetResult(); if (!result.Success) { return(result); } var entity = await _context.ChangeLog.FindAsync(model.Id); if (entity == null) { return(new Result()); } entity = MapCompanyModelToEntity(model, entity); await _context.SaveChangesAsync(); return(result); }