public async Task UpdateScriptLineAsync(ScriptLineModel model) { using (var context = ContextProvider()) { var item = await context.ScriptLine.FirstOrDefaultAsync(x => x.Id == model.Id); if (item != null) { var existingLength = item.Body.Length - model.Body.Length; if (existingLength < 0) { existingLength = existingLength * -1; } if (!string.IsNullOrEmpty(model.Body) && existingLength <= 10) { item.Body = model.Body; } item.CharacterId = model.CharacterId; context.Update(item); await context.SaveChangesAsync(); } } }
public async Task UpdateScriptLine([FromBody] ScriptLineModel model) { await Service.UpdateScriptLineAsync(model); }