Skip to content

Commit

Permalink
added author feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mazumdes committed Feb 3, 2022
1 parent d37d4a4 commit 6670b1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Library.Encyclopedia.API/Controllers/EncylopediaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,21 @@ public async Task<IActionResult> Create([FromBody]Main model)
{
try
{
var response = await mainDataAccess.CreateAsync(model);

if (response == null)
{
return StatusCode(500);
}
else
using (var context = new PrincipalContext(ContextType.Domain | ContextType.Machine))
{
return Ok(response);
var usr = UserPrincipal.FindByIdentity(context, this.HttpContext.User.Identity.Name);
model.Author = usr.DisplayName;

var response = await mainDataAccess.CreateAsync(model);

if (response == null)
{
return StatusCode(500);
}
else
{
return Ok(response);
}
}
}
catch (Exception ex)
Expand Down
1 change: 1 addition & 0 deletions Library.Encyclopedia.Entity/Models/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Main

[StringLength(256)]
public string Category { get; set; }
public string Author { get; set; }

public ICollection<Files> Files { get; set; }
public ICollection<Links> Links { get; set; }
Expand Down

0 comments on commit 6670b1a

Please sign in to comment.