Beispiel #1
0
 public UserService(IUserRepository userRepository, IUnitOfWork unitOfWork, MilkServiceContext context, IMapper mapper)
 {
     _userRepository = userRepository;
     _unitOfWork     = unitOfWork;
     _context        = context;
     _mapper         = mapper;
 }
Beispiel #2
0
        public async Task Invoke(HttpContext httpContext, IUserDetails userDetails, MilkServiceContext context)
        {
            //Alternative method
            //var userDetails = httpContext.RequestServices.GetService<IUserDetails>();
            if (httpContext.Request.Headers.TryGetValue("Token", out StringValues stoken))
            {
                var token       = stoken.SingleOrDefault();
                var userdetails = (from u in context.User
                                   join session in context.UserSession on u.Id equals session.UserId
                                   where session.Token.Equals(token)
                                   select new UserDetails {
                    Id = u.Id,
                    FirstName = u.FirstName,
                    LastName = u.LastName,
                    Email = u.Email,
                    MobileNo = u.MobileNo,
                    Address = u.Address,
                    UserRole = u.UserRole,
                    PINCode = u.Pincode,
                }).FirstOrDefault();

                if (userdetails != null)
                {
                    //userDetails = iMapper.Map<User, UserDetails>(user);
                    userDetails.Id        = userdetails.Id;
                    userDetails.FirstName = userdetails.FirstName;
                    userDetails.LastName  = userdetails.LastName;
                    userDetails.Email     = userdetails.Email;
                    userDetails.MobileNo  = userdetails.MobileNo;
                    userDetails.Address   = userdetails.Address;
                    userDetails.UserRole  = userdetails.UserRole;
                    userDetails.PINCode   = userdetails.PINCode;
                }
            }
            await _next.Invoke(httpContext);
        }
 public BaseRepository(MilkServiceContext context)
 {
     _context = context;
 }
Beispiel #4
0
 public UserRepository(MilkServiceContext context) : base(context)
 {
 }
Beispiel #5
0
 public UnitOfWork(MilkServiceContext context)
 {
     _context = context;
 }