Skip to content

Commit

Permalink
Cwdoe 614 add actions and roles on dashboard (#17)
Browse files Browse the repository at this point in the history
* added version endpoint
* added action and role editing
Co-authored-by: sei-tspencer <trspencer@sei.cmu.edu>
  • Loading branch information
sei-tspencer committed May 9, 2023
1 parent 5d9bb32 commit ee77723
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 4 additions & 2 deletions Cite.Api/Infrastructure/Mappings/ActionProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class ActionProfile : AutoMapper.Profile
{
public ActionProfile()
{
CreateMap<ActionEntity, Action>();
CreateMap<ActionEntity, Action>()
.ForMember(a => a.Team, opt => opt.ExplicitExpansion());

CreateMap<Action, ActionEntity>();
CreateMap<Action, ActionEntity>()
.ForMember(e => e.Team, opt => opt.Ignore());

CreateMap<ActionEntity, ActionEntity>()
.ForMember(e => e.Id, opt => opt.Ignore());
Expand Down
10 changes: 3 additions & 7 deletions Cite.Api/Services/ActionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,18 @@ public async Task<ViewModels.Action> UpdateAsync(Guid id, ViewModels.Action acti
throw new ForbiddenException();

var actionToUpdate = await _context.Actions.SingleOrDefaultAsync(v => v.Id == id, ct);

if (actionToUpdate == null)
throw new EntityNotFoundException<ActionEntity>();

action.CreatedBy = actionToUpdate.CreatedBy;
action.DateCreated = actionToUpdate.DateCreated;
action.ModifiedBy = _user.GetId();
action.DateModified = DateTime.UtcNow;
_mapper.Map(action, actionToUpdate);

actionToUpdate.ModifiedBy = _user.GetId();
actionToUpdate.DateModified = DateTime.UtcNow;
_context.Actions.Update(actionToUpdate);
await _context.SaveChangesAsync(ct);

action = await GetAsync(actionToUpdate.Id, ct);

return action;
return _mapper.Map<ViewModels.Action>(actionToUpdate);
}

public async Task<ViewModels.Action> SetIsCheckedAsync(Guid id, bool value, CancellationToken ct)
Expand Down

0 comments on commit ee77723

Please sign in to comment.