Exemplo n.º 1
0
        public ActionResult SignUpCompany(CompanyRegistrationModel companyRegistration)
        {
            if (!ModelState.IsValid)
            {
                return(View("SignUpCompany", companyRegistration));
            }

            var resourceURI = @"Registration/RegisterCompany";

            UserReturnModel createdUser = null;

            try
            {
                createdUser = this.SendPostRequest <CompanyRegistrationModel, UserReturnModel>(resourceURI, companyRegistration);

                PrepareAndSendConfirmationEmail(createdUser.Email, createdUser.Id, createdUser.UserName);

                TempData["IsEmailSentSuccessfully"] = true;

                return(RedirectToAction("SignUpComplete", "SignUp", new RouteValueDictionary(createdUser)));
            }
            catch (ApiException ex)
            {
                return(View("SignUpCompany", companyRegistration));
            }
            catch (EmailException emailException)
            {
                TempData["IsEmailSentSuccessfully"] = false;

                return(RedirectToAction("SignUpComplete", "SignUp", new RouteValueDictionary(createdUser)));
            }
        }
Exemplo n.º 2
0
        public ActionResult CompanyInsert(CompanyRegistrationModel insert)
        {
            SqlParameter parm;

            try
            {
                DbConnection dbHandle = new DbConnection();
                dbHandle.Connection();
                using (SqlCommand companyRegister = new SqlCommand("USPCompanyRegistration", dbHandle.con))
                {
                    Random random       = new Random();
                    int    randomNumber = random.Next(999999);
                    randomNumber = 1 + randomNumber;
                    string randomNum = randomNumber.ToString();
                    companyRegister.Connection = dbHandle.con;
                    dbHandle.con.Open();
                    companyRegister.CommandType = CommandType.StoredProcedure;
                    parm           = new SqlParameter("@CompanyId", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    companyRegister.Parameters.Add(parm);
                    companyRegister.Parameters.Add("@CompanyName", SqlDbType.VarChar).Value  = insert.companyName;
                    companyRegister.Parameters.Add("@CompanyCode", SqlDbType.VarChar).Value  = insert.companyCode;
                    companyRegister.Parameters.Add("@EmailId", SqlDbType.VarChar).Value      = insert.email;
                    companyRegister.Parameters.AddWithValue("@stateId", SqlDbType.Int).Value = insert.stateId;
                    companyRegister.Parameters.Add("@LandLine", SqlDbType.VarChar).Value     = insert.landLine;
                    companyRegister.Parameters.Add("@MobileNumber", SqlDbType.VarChar).Value = insert.PhoneNumber;
                    companyRegister.Parameters.Add("@CEO", SqlDbType.VarChar).Value          = insert.ceo;
                    companyRegister.Parameters.Add("@otp", SqlDbType.VarChar).Value          = randomNum;
                    SqlDataAdapter da = new SqlDataAdapter(companyRegister);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);
                    int    flag    = Convert.ToInt32(parm.Value);
                    string message = insert.companyName + " Company registered succesfully, For Register Company admin account click this link http://192.168.1.77:80/CompanyRegister/OtpVerification and OTP is " + randomNum;
                    Mail.SendMail(insert.email, "NuNetwork Company Registration", message);
                    Session["companyid"] = flag;
                    dbHandle.con.Close();
                    return(RedirectToAction("OtpVerification", "CompanyRegister"));
                }
            }
            catch (Exception e)
            {
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(RedirectToAction("Error_View", "CompanyRegister"));
            }
            finally
            {
                Dispose();
            }
        }
        public IHttpActionResult CompanySignUp(CompanyRegistrationModel companyRegistrationModel)
        {
            var registerCompanyWithPrincipalUserResult = _businessManager.RegisterCompanyWithPrincipal(companyRegistrationModel.PrimaryUser, companyRegistrationModel.Company);

            if (!registerCompanyWithPrincipalUserResult.IsSuccess)
            {
                return(GetErrorResult(registerCompanyWithPrincipalUserResult));
            }

            var userId   = registerCompanyWithPrincipalUserResult.Result.UserModel.Id;
            var userName = registerCompanyWithPrincipalUserResult.Result.UserModel.UserName;

            Uri locationHeader = new Uri(Url.Link("GetUserById", new { id = userId }));

            return(Created(locationHeader, registerCompanyWithPrincipalUserResult.Result.UserModel));
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> Post([FromBody] CompanyRegistrationModel model)
        {
            var result = await _service.Add(model);

            if (result.statusCode != 0)
            {
                // Send email to confirm account
                var user = await _authorService.GetUserByUserName(model.UserRegisterInfo.UserName);

                string code = await this.UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                var callbackUrl = new Uri(Url.Link("ConfirmCompanyEmail", new { userId = user.Id, code = code }));

                await this.UserManager.SendEmailAsync(user.Id, Common.Constants.EmailMassage.SubjectConfirmEmail, String.Format(Common.Constants.EmailMassage.BodyConfirmEmail, callbackUrl));
            }

            return(Ok(result));
        }
Exemplo n.º 5
0
        // GET: CompanyRegister
        public ActionResult CompanyRegistration()
        {
            try
            {
                CompanyRegistrationModel objuser = new CompanyRegistrationModel();
                if (Session["companyid"] != null)
                {
                    //  return RedirectToAction("UserRegister", "UserRegister");
                }
                objuser.drpStateName = drpList("stateView", "StateName", "StateId");

                return(View(objuser));
            }
            catch (Exception e)
            {
                ExceptionLog.Log(e, Request.UserHostAddress);
                return(RedirectToAction("Error_View", "CompanyRegister"));
            }
            finally
            {
                Dispose();
            }
        }
Exemplo n.º 6
0
        public async Task <IHttpActionResult> Post([FromBody] CompanyRegistrationModel model)
        {
            var result = await _service.Add(model);

            return(Ok(result));
        }
Exemplo n.º 7
0
        public async Task <ResponseBaseModel> Add(CompanyRegistrationModel model)
        {
            ResponseBaseModel ajaxResponse = new ResponseBaseModel();
            ApplicationUser   user         = await _authorRepository.FindUserByEmail(model.UserRegisterInfo.Email);

            if (user != null)
            {
                ajaxResponse.statusCode = (int)HttpStatusCode.Conflict;
                ajaxResponse.statusText = Common.Constants.CompanyMessage.ExistedEmail;

                return(ajaxResponse);
            }

            user = await _authorRepository.FindUser(model.UserRegisterInfo.UserName);

            if (user != null)
            {
                ajaxResponse.statusCode = (int)HttpStatusCode.Conflict;
                ajaxResponse.statusText = Common.Constants.CompanyMessage.ExistedUsername;

                return(ajaxResponse);
            }

            Company company = _repository.FindCompanyByCode(model.CompanyNumber);

            if (company != null)
            {
                ajaxResponse.statusCode = (int)HttpStatusCode.Conflict;
                ajaxResponse.statusText = Common.Constants.CompanyMessage.ExistedCompanyNo;

                return(ajaxResponse);
            }

            Company obj = new Company
            {
                Name = model.Name,
                ContactPersonName         = model.ContactPersonName,
                Address                   = model.Address,
                Website                   = model.Website,
                ContactNumber             = model.ContactNumber,
                CompanyNumber             = model.CompanyNumber,
                BusinessType              = model.BusinessType,
                IsPetronasLicensedCompany = model.IsPetronasLicensedCompany,
                RegistrationSWECCode      = model.RegistrationSWECCode
            };

            //var obj = Mapper.Map<Company>(model);
            var insertedCompany = _repository.Add(obj);
            int code            = await _repository.CommitAsync();

            IdentityResult res = null;

            if (code != 0)
            {
                res = await _authorRepository.RegisterExternalUser(model.UserRegisterInfo, insertedCompany.Id);
            }

            List <Company> _listReturn = new List <Company>();

            _listReturn.Add(insertedCompany);
            ajaxResponse.Data.data  = _listReturn.ToList();
            ajaxResponse.Data.total = 1;
            if (res.Succeeded)
            {
                ajaxResponse.statusCode = code;
            }
            else
            {
                ajaxResponse.statusCode = 0;
            }
            return(ajaxResponse);
        }