Exemplo n.º 1
0
        //private ClsMail Mail;

        public ClsProject(IProjectRepository projectRepository,
                          IClientDetailRepository clientDetailRepository, IUserRepository authorisedPersonRepository,
                          IPromoterRepository promoterRepository, ICostBreakupRepository costBreakupRepository,
                          ICompanyRepository companyRepository, IGroupRepository groupRepository /*, ClsMail mail*/)
        {
            this.ProjectRepository     = projectRepository;
            this.GroupRepository       = groupRepository;
            this.CompanyRepository     = companyRepository;
            this.UserRepository        = authorisedPersonRepository;
            this.PromoterRepository    = promoterRepository;
            this.CostBreakupRepository = costBreakupRepository;
            //this.Mail = mail;
        }
Exemplo n.º 2
0
        public int AddClientDetail(string clientId, AccountModel model, IClientDetailRepository _clientDetailRepo)
        {
            ClientDetail _clientDetail = new ClientDetail
            {
                ClientId    = clientId,
                UserName    = model.UserName,
                FirstName   = model.FirstName,
                LastName    = model.LastName,
                Gender      = model.Gender,
                MobileNo    = Convert.ToInt32(model.PhoneNumber),
                EmailId     = model.Email,
                Jobtype     = model.jobType,
                CountryCode = model.CountryCode,
                CreatedDate = DateTime.Now,
            };

            return(_clientDetailRepo.Insert(_clientDetail));
        }
Exemplo n.º 3
0
 public ClsClientDetail(IClientDetailRepository clientDetailRepository)
 {
     this.ClientDetailRepository = clientDetailRepository;
 }
Exemplo n.º 4
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var userStore       = new UserStore <ApplicationUser>(new ApplicationDbContext());
            var manager         = new UserManager <ApplicationUser>(userStore);
            var userFindByEmail = manager.FindByEmail(context.UserName);
            var user            = userFindByEmail != null ? await manager.FindAsync(userFindByEmail.UserName, context.Password)
                : await manager.FindAsync(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("Please check username and password");
            }
            else
            {
                if (user.JobType == 2)
                {
                    _hospitalDetailsRepository = RepositoryFactory.Create <IHospitalDetailsRepository>(ContextTypes.EntityFramework);
                    hospitalDetails            = _hospitalDetailsRepository.Find(x => x.HospitalId.Trim() == user.Id.Trim()).FirstOrDefault();
                    jobType          = hospitalDetails.jobType;
                    isEmailConfirmed = hospitalDetails.EmailConfirmed;
                }
                else if (user.JobType == 1)
                {
                    _clientDetailRepo = RepositoryFactory.Create <IClientDetailRepository>(ContextTypes.EntityFramework);
                    clientDetailRepo  = _clientDetailRepo.Find(x => x.ClientId.Trim() == user.Id.Trim()).FirstOrDefault();
                    jobType           = clientDetailRepo.Jobtype;
                    isEmailConfirmed  = clientDetailRepo.EmailConfirmed;
                }
                else if (user.JobType == 3)
                {
                    _doctorRepository = RepositoryFactory.Create <IDoctorRepository>(ContextTypes.EntityFramework);
                    doctor            = _doctorRepository.Find(x => x.DoctorId.Trim() == user.Id.Trim()).FirstOrDefault();
                    jobType           = doctor.jobType;
                    isEmailConfirmed  = true;
                }
                else if (user.JobType == 4)
                {
                    _secretaryRepository = RepositoryFactory.Create <ISecretaryRepository>(ContextTypes.EntityFramework);
                    secretary            = _secretaryRepository.Find(x => x.SecretaryId.Trim() == user.Id.Trim()).FirstOrDefault();
                    jobType          = secretary.jobType;
                    isEmailConfirmed = true;
                }
                else
                {
                    _hospitalDetailsRepository = RepositoryFactory.Create <IHospitalDetailsRepository>(ContextTypes.EntityFramework);
                    hospitalDetails            = _hospitalDetailsRepository.Find(x => x.HospitalId.Trim() == user.Id.Trim()).FirstOrDefault();
                    jobType          = hospitalDetails.jobType;
                    isEmailConfirmed = hospitalDetails.EmailConfirmed;
                }
                if (!isEmailConfirmed)
                {
                    context.SetError("Please verify your email address");
                }
                else
                {
                    var identity = new ClaimsIdentity(context.Options.AuthenticationType);
                    identity.AddClaim(new Claim("UserId", user.Id));
                    identity.AddClaim(new Claim("Username", user.UserName));
                    identity.AddClaim(new Claim("Email", user.Email));
                    identity.AddClaim(new Claim("FirstName", user.FirstName));
                    identity.AddClaim(new Claim("LastName", user.LastName == null ? "" : user.LastName));
                    identity.AddClaim(new Claim("LoggedOn", DateTime.Now.ToString()));
                    identity.AddClaim(new Claim("PhoneNo", user.PhoneNumber == null ? " " : user.PhoneNumber));
                    identity.AddClaim(new Claim("JobType", user.JobType.ToString()));
                    context.Validated(identity);
                }
            }
        }