Esempio n. 1
0
        public ActionResult SetAdminRole(string sType, string sUser)
        {
            ApplicationUser user = UserManager.FindByName <ApplicationUser, string>(sUser);

            Models.DBContext      dbContext = new Models.DBContext();
            Models.CompanyDetails cmp       = new Models.CompanyDetails();
            var FindCompany = (from d in dbContext.Company
                               where d.CompanyName == user.CompanyName
                               select new { d.CompanyName, d.Logo }).FirstOrDefault();

            if (sType == "Y")
            {
                cmp.CompanyName = user.CompanyName;
                cmp.EmailID     = user.Email;
                cmp.UserName    = user.UserName;
                cmp.Logo        = FindCompany.Logo;
                dbContext.Company.Add(cmp);
                dbContext.SaveChanges();
            }
            else
            {
                var userdata = dbContext.Company.Where(D => D.UserName == sUser).FirstOrDefault();
                dbContext.Company.Remove(userdata);
                dbContext.SaveChanges();
            }

            return(View());
        }
        public ActionResult UserRegister()
        {
            Models.DBContext      dbContext = new Models.DBContext();
            Models.CompanyDetails cmp       = new Models.CompanyDetails();
            var FindCompany = (from d in dbContext.Company
                               where d.UserName == User.Identity.Name
                               select new { d.CompanyName }).ToList();

            string CompanyName = FindCompany[0].CompanyName;

            ViewBag.CompanyName   = CompanyName;
            ViewBag.ErrorMessage  = "";
            ViewBag.InitialValues = JsonConvert.SerializeObject((from iv in db.InitializeTables where iv.CompanyName == CompanyName select iv).FirstOrDefault());

            RegisterModel model = new RegisterModel();

            model.UserName            = "";
            model.CompanyName         = ViewBag.CompanyName;
            model.Email               = "";
            model.Upload              = "";
            model.Password            = "";
            model.ConfirmPassword     = "";
            model.ConfirmPassword     = "";
            model.ConfirmPasswordName = "";
            model.RequestType         = "Individual";

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult UserRegister()
        {
            Models.DBContext      dbContext = new Models.DBContext();
            Models.CompanyDetails cmp       = new Models.CompanyDetails();
            var FindCompany = (from d in dbContext.Company
                               where d.UserName == User.Identity.Name
                               select new { d.CompanyName }).ToList();

            ViewBag.CompanyName = FindCompany[0].CompanyName;
            return(View());
        }
Esempio n. 4
0
        // POST: /Account/UploadLogo
        public ActionResult UploadLogo(HttpPostedFileBase file)
        {
            Models.DBContext      dbContext = new Models.DBContext();
            Models.CompanyDetails cmp       = new Models.CompanyDetails();
            var FindCompany = dbContext.Company.Where(C => C.UserName == User.Identity.Name).FirstOrDefault();

            if (file != null)
            {
                string pic  = System.IO.Path.GetFileName(file.FileName);
                string path = System.IO.Path.Combine(
                    Server.MapPath("~/Content/assets/CompanyLogo/"), pic);
                // file is uploaded
                file.SaveAs(path);

                if (FindCompany != null)
                {
                    FindCompany.Logo = pic;
                    dbContext.SaveChanges();
                }
                ViewBag.UploadSuccess = "Logo Uploaded Successfully, Please click on the link to dashboard list";
            }

            return(View());
        }
Esempio n. 5
0
        public async Task <ActionResult> Register(RegisterModel model, string cbxDataPrivacy)
        {
            if (cbxDataPrivacy == "on")
            {
                Models.DBContext      dbContext = new Models.DBContext();
                Models.CompanyDetails cmp       = new Models.CompanyDetails();
                var FindCompany = (from d in dbContext.Company
                                   where d.CompanyName == model.CompanyName
                                   select new { d.CompanyName }).ToList();

                if (ModelState.IsValid)
                {
                    // Attempt to register the user

                    if (FindCompany.Count == 0)
                    {
                        var user = new ApplicationUser {
                            UserName = model.UserName, Email = model.Email, CompanyName = model.CompanyName
                        };
                        var result = await UserManager.CreateAsync(user, model.Password);

                        if (result.Succeeded)
                        {
                            cmp.CompanyName = user.CompanyName;
                            cmp.EmailID     = user.Email;
                            cmp.UserName    = user.UserName;
                            cmp.Logo        = null;
                            dbContext.Company.Add(cmp);
                            dbContext.SaveChanges();

                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                            // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                            // Send an email with this link
                            string EMail = ConfigurationManager.AppSettings.Get("EmailID");
                            string To = EMail, UserID, Password, SMTPPort, Host;

                            var    request = HttpContext.Request;
                            string lnkHref = "<a href='" + HttpContext.Request.Url.Scheme + "://" +
                                             HttpContext.Request.Url.Authority +
                                             "/Home/ApprovalList/?CustRegId=" + user.Id +
                                             "'>" + "Approval link" + "</a>";

                            //HTML Template for Send email
                            string subject = "Request for Approval of subscription";
                            string body    = "<b>Dear Admin, </b><br/><br/>";
                            body = body + "<b>Kindly Approve The Customer: " + user.CompanyName + "&nbsp; Request for enrollement.</b><br/>" + "<b>Please find the Customers list </b>&nbsp; : " + lnkHref;
                            body = body + "<br/><br/><b>Thanks,</b><br/>" + "<b>Mcbitss Team.</b>";

                            //Get and set the AppSettings using configuration manager.
                            EmailManager.AppSettings(out UserID, out Password, out SMTPPort, out Host);

                            //Call send email methods.
                            EmailManager.SendEmail(UserID, subject, body, To, UserID, Password, SMTPPort, Host);

                            return(Redirect("/"));
                        }

                        ViewBag.ErrorMessage = result.Errors.First();
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "Company details are already added";
                    }
                }
            }
            else
            {
                ViewBag.ErrorMessage = "Please accept data privacy policy && Terms";
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task <ActionResult> Register(RegisterModel model, string cbxDataPrivacy)
        {
            if (cbxDataPrivacy == "on")
            {
                Models.DBContext      dbContext = new Models.DBContext();
                Models.CompanyDetails cmp       = new Models.CompanyDetails();
                var FindCompany = (from d in dbContext.Company
                                   where d.CompanyName == model.CompanyName
                                   select new { d.CompanyName }).ToList();

                string wcCompanyName = ConfigurationManager.AppSettings["wcCompanyName"].ToString();
                var    INI           = (from ini in dbContext.InitializeTables
                                        where ini.Authentication.ToUpper() == "WINDOWS" && ini.CompanyName == wcCompanyName
                                        select ini).FirstOrDefault();
                if (INI != null)
                {
                    string[] WindowsUser    = Request.LogonUserIdentity.User.ToString().Split('\\');
                    string   WindowUserName = WindowsUser[0];
                    if (WindowsUser.Length >= 2)
                    {
                        WindowUserName = WindowsUser[1];
                    }
                    model.UserName = WindowUserName;
                }

                if (ModelState.IsValid)
                {
                    // Attempt to register the user
                    if (FindCompany.Count == 0)
                    {
                        var user = new ApplicationUser {
                            UserName    = model.UserName,
                            Email       = model.Email,
                            CompanyName = model.CompanyName
                        };
                        var result = await UserManager.CreateAsync(user, model.Password);

                        if (result.Succeeded)
                        {
                            cmp.CompanyName = user.CompanyName;
                            cmp.EmailID     = user.Email;
                            cmp.UserName    = user.UserName;
                            cmp.Logo        = null;
                            dbContext.Company.Add(cmp);

                            Models.UserRoles usr = new Models.UserRoles();
                            usr.UserId      = model.UserName;
                            usr.Role        = model.Roles;
                            usr.CompanyName = user.CompanyName;
                            usr.Email       = model.Email;
                            dbContext.UserRoles.Add(usr);
                            dbContext.SaveChanges();

                            using (SqlCommand cmd = new SqlCommand())
                            {
                                cmd.CommandType    = CommandType.StoredProcedure;
                                cmd.CommandTimeout = 0;
                                cmd.CommandText    = "PROC_CONFIGURE_COMPANY";

                                cmd.Parameters.Add("@CURRENT_COMPANY", SqlDbType.VarChar, 500).Value   = ConfigureCompany;
                                cmd.Parameters.Add("@CONFIGURE_COMPANY", SqlDbType.VarChar, 500).Value = user.CompanyName;

                                Common csobj = new Common();
                                csobj.SPReturnDataTable(cmd);
                            }


                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                            // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                            // Send an email with this link
                            string EMail = ConfigurationManager.AppSettings.Get("EmailID");
                            string To = model.Email, UserID, Password, SMTPPort, Host;

                            var    request = HttpContext.Request;
                            string lnkHref = "<a href='" + HttpContext.Request.Url.Scheme + "://" +
                                             HttpContext.Request.Url.Authority +
                                             "/Home/ApprovalList/?CustRegId=" + user.Id +
                                             "'>" + "Approval link" + "</a>";

                            //HTML Template for Send email
                            string subject = "Request for Approval of subscription";
                            string body    = "<b>Dear Admin, </b><br/><br/>";
                            body = body + "<b>Kindly Approve The Customer: " + user.CompanyName + "&nbsp; Request for enrollement.</b><br/>" + "<b>Please find the Customers list </b>&nbsp; : " + lnkHref;
                            body = body + "<br/><br/><b>Thanks,</b><br/>" + "<b>Mcbitss Team.</b>";

                            //Get and set the AppSettings using configuration manager.
                            EmailManager.AppSettings(out UserID, out Password, out SMTPPort, out Host);

                            //Call send email methods.
                            EmailManager.SendEmail(UserID, subject, body, To, UserID, Password, SMTPPort, Host);

                            return(Redirect("~/"));
                        }

                        ViewBag.ErrorMessage = result.Errors.First();
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "Company details are already added";
                    }
                }
            }
            else
            {
                ViewBag.ErrorMessage = "Please accept data privacy policy && Terms";
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }