Robin Groot
Robin Groot

Reputation: 92

Current user in class

I want to get the current user and fill it in the currentuser at the moment I make a new article just like when I make a new date at the moment I make the article.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;

namespace CeeLearnAndDo.Models
{
    public class Article
    {
        public int Id { get; set; }
        public string CurentUser { get; set; }
        public string Title { get; set; }
        public DateTime CreationDate { get; set; }
        public string Content { get; set; }
        public Article()
        {
            CreationDate = DateTime.Now;
            CurentUser = 
        }
    }
}

If you need anymore info just ask me.

Upvotes: 0

Views: 210

Answers (1)

erdi yılmaz
erdi yılmaz

Reputation: 348

CurentUser = User.Identity.Name;

Upvotes: 2

Related Questions