Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.Entity;
- using TOM.Services.SQL.EF;
- using TOM.Services;
- using TOM.Models;
- namespace TOM.Services
- {
- //IUserService = Interface
- public class UserRepository : IUserService
- {
- private TOMEntities _context;
- public UserRepository(TOMEntities context)
- {
- _context = context;
- }
- public SQL.EF.User GetUser(string userName)
- {
- return _context.Users.FirstOrDefault(x => x.UserName == userName);
- }
- public List<SQL.EF.User> CreateNewUser()
- {
- var userResult = from b in _context.Users
- select new TOM.Services.SQL.EF.User()
- {
- FirstName = b.FirstName,
- LastName = b.LastName,
- PhoneNumber = b.PhoneNumber,
- UserName = b.UserName,
- OrganizationId = b.OrganizationId,
- Activated = b.Activated,
- RegistrationReasonId = b.RegistrationReasonId,
- Admin = b.Admin,
- SuperAdmin = b.SuperAdmin,
- Created = b.Created,
- CreatedBy = b.CreatedBy,
- Password = b.Password,
- Salt = b.Salt,
- };
- _context.SaveChanges();
- return userResult.ToList();
- }
- //INTERFACE
- using SIA.Models;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TOM.Services.SQL.EF;
- namespace SIA.Services
- {
- public interface IUserService
- {
- SQL.EF.User GetUser(string userName);
- List<SQL.EF.User> CreateNewUser();
- }
- }
- //SERVICE
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SIA.Models;
- using System.Net.Mail;
- using System.Net;
- using System.Configuration;
- using SIA.Services.SQL.EF;
- namespace SIA.Services
- {
- public class UserService
- {
- //private string _username;
- private IUserService _userRepository;
- public UserService(IUserService userRepository)
- {
- _userRepository = userRepository;
- }
- public bool UserExist(string userName)
- {
- var user = _userRepository.GetUser(userName);
- return user != null;
- }
- public SQL.EF.User CreateNewUser()
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement