コード例 #1
0
        public async Task <IActionResult> AddUserprofile(UserProfileDTO userprofileDTO)
        {
            try
            {
                //var userid = _accessor.HttpContext.User.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).SingleOrDefault();

                var userid = "36198786-9A70-4BCE-ECB1-08D8151C3370";

                var result = await _userprofile.AddUserProfile(userprofileDTO);

                if (result.Success == false)
                {
                    return(BadRequest(result));
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #2
0
        public ActionResult AddProfile(UserProfile profile)
        {
            int userId = Convert.ToInt32(Session["UserId"]);

            try
            {
                //bool result = int.TryParse((string)Session["UserId"], out userId);
                //if (result)
                //{
                profile.UserId = userId;
                _userProfileRepo.AddUserProfile(profile);
                return(RedirectToAction("GetProfile"));
                // }
            }
            catch (Exception e)
            {
                //Console.WriteLine(e);
                //throw;
                return(View());
            }
            //return View();
        }
コード例 #3
0
        public IHttpActionResult UserRegister(UserRegisterRequest registerRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var account = new Account()
                {
                    Mobile = registerRequest.Mobile
                };
                int resultCheckUserExists = iAccount.CheckUserExists(account);
                if (resultCheckUserExists == 0)
                {
                    if (registerRequest.RoleId == Convert.ToInt32(Utility.Roles.User))
                    {
                        string mobileOTP = Utility.RandomOtpMobile();
                        string emailOTP  = Utility.RandomOtpEmail();

                        string oTPResult = Utility.SendOTPOnSMS(registerRequest.Mobile, Utility.LoginRegister.Register.ToString(), mobileOTP);

                        dynamic deserializeOTPResult = JsonConvert.DeserializeObject <dynamic>(oTPResult);

                        if (deserializeOTPResult.Status == Utility.SUCCESS_STATUS_RESPONSE)
                        {
                            var userProfile = new UserProfile()
                            {
                                RoleId      = registerRequest.RoleId,
                                UserName    = registerRequest.UserName,
                                Mobile      = registerRequest.Mobile,
                                MobileOTP   = mobileOTP,
                                EmailOTP    = emailOTP,
                                FirstName   = registerRequest.FirstName,
                                LastName    = registerRequest.LastName,
                                Gender      = registerRequest.Gender,
                                CompanyName = registerRequest.CompanyName,
                                ProfessionalQualificationId = registerRequest.ProfessionalQualificationId
                            };
                            int result = iUserProfile.AddUserProfile(userProfile);

                            if (result > 0)
                            {
                                var welComeEmailHtmlCode = System.IO.File.ReadAllText(string.Format("{0}", HttpContext.Current.Server.MapPath(string.Format("{0}{1}", ConfigurationManager.AppSettings["EmailTemplatePath"], ConfigurationManager.AppSettings["WelcomeForUserEmailTemplate"]))));
                                welComeEmailHtmlCode = welComeEmailHtmlCode.Replace("[EMAILID]", registerRequest.UserName);
                                welComeEmailHtmlCode = welComeEmailHtmlCode.Replace("[EMAILOTP]", emailOTP);
                                welComeEmailHtmlCode = welComeEmailHtmlCode.Replace("[SITEURL]", ConfigurationManager.AppSettings["SiteUrl"]);
                                welComeEmailHtmlCode = welComeEmailHtmlCode.Replace("[SITENAME]", ConfigurationManager.AppSettings["SiteName"]);

                                var mainTemplateHtmlCode = System.IO.File.ReadAllText(string.Format("{0}", HttpContext.Current.Server.MapPath(string.Format("{0}{1}", ConfigurationManager.AppSettings["EmailTemplatePath"], ConfigurationManager.AppSettings["MainEmailTemplate"]))));
                                mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[SITEURL]", ConfigurationManager.AppSettings["SiteUrl"]);
                                mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[SITENAME]", ConfigurationManager.AppSettings["SiteName"]);
                                mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[PAGECONTENT]", welComeEmailHtmlCode);

                                string subject     = "Welcome in Demystify Fema";
                                string body        = mainTemplateHtmlCode;
                                string displayName = ConfigurationManager.AppSettings["SiteName"];
                                bool   isSentMail  = Utility.SendMail(registerRequest.UserName, string.Empty, string.Empty, subject, body, displayName, string.Empty, true);

                                if (isSentMail)
                                {
                                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                                    responses.Description = "User added successfully. Please verify account by entering OTP which you have received in email and mobile.";
                                }
                                else
                                {
                                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                                    responses.Description = "Error while sending OTP.";
                                }
                            }
                            else if (result == -2)
                            {
                                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                                responses.Description = "Another user is already registered with same mobile.";
                            }
                            else
                            {
                                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                                responses.Description = "Error while adding user.";
                            }
                        }
                        else
                        {
                            responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                            responses.Description = "Error while sending OTP.";
                        }
                    }
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Another user is already registered with same mobile.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while registration.";

                Utility.WriteLog("Register", registerRequest, "Error while registration. (AccountGuestController)", ex.ToString());
            }
            return(Ok(responses));
        }