public async Task <ActionResult <Guid> > Create(TaskStatus status, CancellationToken ct = default) { status.AccountId = _userContext.AccountId; var id = await _taskStatusesService.CreateAsync(_userContext.UserId, status, ct); return(Created("Get", id)); }
public async Task <ActionResult> Update(TaskStatus status, CancellationToken ct = default) { var oldStatus = await _taskStatusesService.GetAsync(status.Id, true, ct); if (oldStatus == null) { return(NotFound(status.Id)); } return(await ActionIfAllowed( () => _taskStatusesService.UpdateAsync(_userContext.UserId, oldStatus, status, ct), Roles.Tasks, oldStatus.AccountId)); }
public async Task UpdateAsync( Guid userId, TaskStatus oldStatus, TaskStatus newStatus, CancellationToken ct) { var change = oldStatus.UpdateWithLog(userId, x => { x.Name = newStatus.Name; x.IsFinish = newStatus.IsFinish; x.IsDeleted = newStatus.IsDeleted; x.ModifyDateTime = DateTime.UtcNow; }); _storage.Update(oldStatus); await _storage.AddAsync(change, ct); await _storage.SaveChangesAsync(ct); }
public async Task <Guid> CreateAsync(Guid userId, TaskStatus status, CancellationToken ct) { var newStatus = new TaskStatus(); var change = newStatus.CreateWithLog(userId, x => { x.Id = status.Id; x.AccountId = status.AccountId; x.Name = status.Name; x.IsFinish = status.IsFinish; x.IsDeleted = status.IsDeleted; x.CreateDateTime = DateTime.UtcNow; }); var entry = await _storage.AddAsync(newStatus, ct); await _storage.AddAsync(change, ct); await _storage.SaveChangesAsync(ct); return(entry.Entity.Id); }