Exemplo n.º 1
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();


            ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "The user name or password is incorrect.");
                return;
            }

            ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                OAuthDefaults.AuthenticationType);

            ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                  CookieAuthenticationDefaults.AuthenticationType);

            AuthenticationProperties properties = CreateProperties(user.UserName);

            var AllUser   = interfaceObj.GetModel();
            var regUserId = AllUser.Where(x => x.UserId == user.Id).Select(x => x.Id).FirstOrDefault();


            RegisterUser RUserData = new RegisterUser();

            var Udata = interfaceObj.GetModelById(Convert.ToInt32(regUserId));

            properties.Dictionary.Add("Id", Udata.Id.ToString());
            properties.Dictionary.Add("FirstName", Udata.FirstName);
            properties.Dictionary.Add("MiddelName", Udata.MiddelName);
            properties.Dictionary.Add("LastName", Udata.LastName);
            properties.Dictionary.Add("Email", Udata.Email);
            properties.Dictionary.Add("Phone", Udata.Phone);
            properties.Dictionary.Add("Role", Udata.Role);

            string base64String = null;
            string path         = System.Web.HttpContext.Current.Server.MapPath(Udata.Image);

            using (System.Drawing.Image image = System.Drawing.Image.FromFile(path))
            {
                using (MemoryStream m = new MemoryStream())
                {
                    image.Save(m, image.RawFormat);
                    byte[] imageBytes = m.ToArray();
                    base64String = Convert.ToBase64String(imageBytes);
                }
            }
            properties.Dictionary.Add("Image", base64String);


            AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties);

            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);
        }
Exemplo n.º 2
0
        public IEnumerable <CSkill> GetSkills()
        {
            var SkillList = skillObj.GetModel().Select(x => new CSkill
            {
                SkillName = x.SkillName
            });

            return(SkillList);
        }
Exemplo n.º 3
0
        public IEnumerable <CCountry> GetCountry()
        {
            var Countrylist = countryObj.GetModel().Select(x => new CCountry
            {
                Id          = x.Id,
                CountryName = x.CountryName
            });

            return(Countrylist);
        }
Exemplo n.º 4
0
        public IEnumerable <CState> GetState()
        {
            var Statelist = stateObj.GetModel().Select(x => new CState
            {
                Id        = x.Id,
                StateName = x.StateName,
                CountryId = x.CountryId
            });

            return(Statelist);
        }
Exemplo n.º 5
0
        public IEnumerable <CCity> GetCity()
        {
            var Citylist = cityObj.GetModel().Select(x => new CCity
            {
                Id        = x.Id,
                CityName  = x.CityName,
                CountryId = x.CountryId,
                StateId   = x.StateId
            });

            return(Citylist);
        }
Exemplo n.º 6
0
        public IEnumerable <CEmployee> GetAllEmployee()
        {
            try
            {
                var employeelist = EmployeeObj.GetModel().Select(x => new CEmployee
                {
                    Id          = x.Id,
                    UserId      = x.UserId,
                    FirstName   = x.FirstName,
                    MiddelName  = x.MiddelName,
                    LastName    = x.LastName,
                    BirthDate   = x.BirthDate,
                    Gender      = x.Gender,
                    Designation = x.Designation,
                    Image       = x.Image.Split('~')[1],
                    //ImageBase64 = Base64(x.Image),
                    Role         = x.Role,
                    Department   = x.Department,
                    JoinDate     = x.JoinDate,
                    Email        = x.Email,
                    Password     = x.Password,
                    Address      = x.Address,
                    Skill        = x.Skill,
                    Mobile       = x.Mobile,
                    Description  = x.Description,
                    Country      = x.Country,
                    CountryName  = GetCountryName(x.Country),
                    State        = x.State,
                    StateName    = GetStateName(x.State),
                    City         = x.City,
                    CityName     = GetCityName(x.City),
                    ZipCode      = x.ZipCode,
                    Relationship = x.Relationship
                });

                return(employeelist);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }