Example #1
0
        public ResRegistration Registration(ReqRegistration reqRegistration)
        {
            if (String.IsNullOrEmpty(reqRegistration.Password))
            {
                Random rnd = new Random();
                var    a   = StaticConst.Caps[rnd.Next(StaticConst.Caps.Length)].ToString();
                var    b   = StaticConst.Special[rnd.Next(0, StaticConst.Special.Length)].ToString();
                var    c   = StaticConst.Small[rnd.Next(0, StaticConst.Small.Length)].ToString() + StaticConst.Special[rnd.Next(0, StaticConst.Special.Length)].ToString();
                var    d   = StaticConst.Num[rnd.Next(0, StaticConst.Num.Length)].ToString() + StaticConst.Small[rnd.Next(0, StaticConst.Small.Length)].ToString();

                reqRegistration.Password = a + b + c + d;
            }
            ResRegistration resRegistration = new ResRegistration();

            resRegistration = Common <ReqRegistration, ResRegistration> .Serialize_Deserialize(reqRegistration, resRegistration, StaticConst.SP_USERREGISTRATION);

            if (resRegistration.ResponseCode == 1 || resRegistration.ResponseCode == 2)
            {
                ReqEmail reqEmail = new ReqEmail();
                reqEmail.EmailId  = reqRegistration.EmailId;
                reqEmail.UserName = reqRegistration.Name;
                CallThirdParty.SendMailCustom(reqEmail, reqRegistration.Password);
            }
            //CallThirdParty.SendDefaultPassword(reqRegistration.ContactNo, reqRegistration.Password);
            return(resRegistration);
        }
        public int UserRegistration(ReqRegistration objReq)
        {
            int rst = 0;
            try
            {
                using (var db = new UnseentalentdbDataContext())
                {
                    User user = db.Users.FirstOrDefault(p => p.Email == objReq.emailId.ToLower());
                    if (user == null)
                    {
                        var objNew = new User();
                        objNew.UserName = objReq.userName;
                        objNew.Email = objReq.emailId.ToLower();
                        objNew.Password = objReq.password;
                        objNew.CreatedDate = DateTime.UtcNow;
                        objNew.IsActive = false;
                        objNew.IsDeleted = false;
                        objNew.IsToken = true;
                        objNew.ProfilePic = objReq.image;
                        objNew.NumberOfToken = 0;
                        db.Users.InsertOnSubmit(objNew);
                        db.SubmitChanges();

                        /*var objRole = new tbl_userrole();
                        objRole.createdate = DateTime.UtcNow;
                        objRole.isactive = false;
                        objRole.userid = objNew.id;
                        objRole.isdeleted = false;
                        objRole.userrole = 2;
                        db.tbl_userroles.InsertOnSubmit(objRole);*/
                        var objRole = new UserRole();
                        objRole.UserId = objNew.Id;
                        Role firstOrDefault =
                            GetAllRole().FirstOrDefault(r => r.Name == CommonHelpers.ToEnumDescription(RolesEnum.User));
                        objRole.RoleId = firstOrDefault.Id;
                        db.UserRoles.InsertOnSubmit(objRole);

                        db.SubmitChanges();

                        rst = 1; //Successfully Registred
                        SendVerifyEmail(objReq.emailId.ToLower(), "1", objNew.Id);
                    }
                    else if (user.IsActive == false)
                    {
                        rst = 1; //Successfully Registred
                        SendVerifyEmail(objReq.emailId.ToLower(), "1", user.Id);
                    }
                    else
                    {
                        rst = 3; //Email Id already exists
                    }
                }
            }
            catch
            {
                rst = 2; //Error Occured
            }
            return rst;
        }
        public Response<int> UserRegistration(ReqRegistration objreq)
        {
            int rst = 0;
            var objresponse = new Response<int>();
            var objmethod = new UnseenTalentsMethod();

            try
            {
                rst = objmethod.UserRegistration(objreq);
                objresponse.Create(true, 0, "User Registration Success", rst);
            }
            catch (Exception ex)
            {
                objresponse.Create(false, -1, "User Registration Failed", rst);
            }
            return objresponse;
        }
        public Response<int> UserRegistration(ReqRegistration objreq)
        {
            int rst = 0;
            Response<int> objresponse = new Response<int>();
            UnseenTalentsMethod objmethod = new UnseenTalentsMethod();

            try
            {
                rst = objmethod.UserRegistration(objreq);
                objresponse.Create(true, 0, "Events for admin", rst);

            }
            catch (Exception ex)
            {
                objresponse.Create(false, -1, "", rst);
            }
            return objresponse;
        }