Ejemplo n.º 1
0
        public static StringBuilder NewUserUpdate(SCL_Users UserData)
        {
            StringBuilder strBulBodyContent = new StringBuilder();

            strBulBodyContent.Append("<html>");
            strBulBodyContent.Append("<head>");
            strBulBodyContent.Append("</head>");
            strBulBodyContent.Append("<body>");
            strBulBodyContent.Append("<div>");
            strBulBodyContent.Append("<div>Dear User, your account details has been updated.</div><br /><br/>");
            strBulBodyContent.Append("<div>Account details</div><br/>");
            //strBulBodyContent.Append("<div>Username: "******"</div><br/>");
            strBulBodyContent.Append("<div>Email ID: " + UserData.EmailID + "</div><br/>");
            strBulBodyContent.Append("<div>Click the below link to login to your account to view your updated details.</div><br/>");

            string baseUrl = HttpContext.Current.Request.Url.Authority;

            //Encrypter enc = new Encrypter();
            //string url = string.Format("{0}/Master/ActivateUser?e1={1}&e2={2}&e3={3}", baseUrl, enc.Encrypt(UserData.ID.ToString()), enc.Encrypt(UserData.CompanyID.ToString()), enc.Encrypt(UserData.EmailID.ToString()));

            string url = "http://" + baseUrl;

            //strBulBodyContent.Append("<div><a href='" + baseUrl + "'>Go to AssetManagement</a></div><br/>");

            strBulBodyContent.Append("<a href='" + baseUrl + "' style='cursor:pointer'><input type='button' value='Go to Leads' style='height:50px;width:200px;background-color:green;border-radius:3px;color:white' /></a>");

            strBulBodyContent.Append("<br/><br/><br/>Regards<br />");
            strBulBodyContent.Append("Leads Team.");
            strBulBodyContent.Append("</div>");
            strBulBodyContent.Append("</body>");
            strBulBodyContent.Append("</html>");
            return(strBulBodyContent);
        }
Ejemplo n.º 2
0
        public static string NewUserUpdate(string fromMail, SCL_Users UserData)
        {
            string emailStatus = "";
            string fromName    = "Leads";
            string bodyHtml    = NotificationBodyData1.NewUserUpdate(UserData).ToString();
            string bodyText    = "";

            string heading = "User Account Details Updated";

            emailStatus = Elasticmail.SendEmail(UserData.EmailID, heading, bodyText, bodyHtml, fromMail, fromName, "");
            return(emailStatus);
        }
Ejemplo n.º 3
0
        public ActionResult CreateNewUser(SCL_Users UserFormData, string password, string SaveType)
        {
            //if (Session["AMUSERDATA_USER_NAME"] == null)
            //{
            //    Dictionary<string, object> dic1 = new Dictionary<string, object>();
            //    dic1.Add("expire", true);
            //    return Json(dic1, JsonRequestBehavior.AllowGet);
            //}

            Dictionary <string, object> dic = SaveType == "Add" ? asData.CreateNewUser(UserFormData, password) : asData.UpdateUser(UserFormData);
            var result = Json(dic, JsonRequestBehavior.AllowGet);

            result.MaxJsonLength = Int32.MaxValue;

            return(result);
        }
Ejemplo n.º 4
0
        public Dictionary <string, object> addCompany(HttpFileCollectionBase files, string FreeTrail, SCL_CompanyRegistration UserFormData, string Browser)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();
            var subDate    = DateTime.Now;
            var SubEndDate = DateTime.Now;

            if (FreeTrail.Equals("YES"))
            {
                SubEndDate = subDate.AddDays(30);
            }
            else
            {
                SubEndDate = subDate.AddDays(10);
            }

            using (var tran = gc.db.Database.BeginTransaction())
            {
                try
                {
                    string file_name = "";
                    string fname     = "";

                    List <string> fileNameList = new List <string>();

                    if (files.Count > 0)
                    {  //  Get all files from Request object
                        for (int i = 0; i < files.Count; i++)
                        {
                            HttpPostedFileBase file = files[i];

                            if (Browser == "IE" || Browser == "INTERNETEXPLORER")
                            {
                                string[] testfiles = file.FileName.Split(new char[] { '\\' });
                                fname = testfiles[testfiles.Length - 1];
                            }
                            else
                            {
                                fname = file.FileName;
                            }

                            fname     = file.FileName;
                            file_name = string.Format("{0}-{1}", DateTime.Now.ToString("ddMMMyyyyHHmmss"), fname.Replace("-", ""));
                            fname     = Path.Combine(HttpContext.Current.Server.MapPath("~/Attachments/"), file_name);
                            file.SaveAs(fname);

                            fileNameList.Add(file_name);
                        }
                    }

                    //string password_ln = CreateRandomPassword(8);
                    string body = "Welcome to Leads Portal.\n\nYour Account Details are \n\n username: "******"\n\n Password: "******"\n\n\n Thank You\n\n";

                    UserFormData.company_status      = "Active";
                    UserFormData.cdate               = subDate;
                    UserFormData.Flag                = FreeTrail;
                    UserFormData.SubscriptionEndDate = SubEndDate;
                    UserFormData.company_uniqueID    = "Not Required";
                    UserFormData.ProfilePicture      = fileNameList[0];
                    gc.db.SCL_CompanyRegistration.Add(UserFormData);

                    int n = gc.db.SaveChanges();
                    if (n > 0)
                    {
                        SCL_UserRoles role = new SCL_UserRoles();
                        role.RoleName        = "Admin";
                        role.CreatedBy       = UserFormData.CID;
                        role.CompanyID       = UserFormData.CID;
                        role.CreatedDateTime = subDate;
                        role.Status          = "Active";
                        gc.db.SCL_UserRoles.Add(role);
                        gc.db.SaveChanges();

                        SCL_UserDepartments dep = new SCL_UserDepartments();
                        dep.DepartmentName  = "Admin";
                        dep.CreatedBy       = UserFormData.CID;
                        dep.CompanyID       = UserFormData.CID;
                        dep.CreatedDateTime = subDate;
                        dep.Status          = "Active";
                        gc.db.SCL_UserDepartments.Add(dep);

                        gc.db.SaveChanges();

                        SCL_Users users = new SCL_Users();
                        users.UserName        = UserFormData.company_email;
                        users.UserPass        = UserFormData.company_password;
                        users.RoleID          = role.ID;
                        users.DepartmentID    = dep.DepartmentID;
                        users.FirstName       = UserFormData.first_name;
                        users.LastName        = UserFormData.last_name;
                        users.EmailID         = UserFormData.company_email;
                        users.CompanyID       = UserFormData.CID;
                        users.Status          = "Active";
                        users.CreatedBy       = UserFormData.CID;
                        users.CreatedDateTime = subDate;
                        users.userType        = "Admin";
                        gc.db.SCL_Users.Add(users);
                        int x = gc.db.SaveChanges();

                        List <SCL_UserRoleScreenMapping> RoleScreenList = gc.db.SCL_UserRoleScreenMapping
                                                                          .Where(u => u.RoleID == users.RoleID && u.CompanyID == users.CompanyID).ToList();

                        foreach (SCL_UserRoleScreenMapping g in RoleScreenList)
                        {
                            SCL_UserwiseScreenMapping USM = new SCL_UserwiseScreenMapping();
                            USM.CompanyID       = users.CompanyID;
                            USM.CreatedBy       = users.CompanyID;
                            USM.CreatedDateTime = subDate;
                            USM.ScreenID        = g.ScreenID;
                            USM.UserID          = users.ID;

                            gc.db.SCL_UserwiseScreenMapping.Add(USM);
                        }

                        gc.db.SaveChanges();

                        SCL_Login login = new SCL_Login();
                        login.CID                 = UserFormData.CID;
                        login.username            = UserFormData.company_email;
                        login.password            = UserFormData.company_password;
                        login.status              = "Active";
                        login.cdate               = subDate;
                        login.type                = "ADMIN";
                        login.SubscriptionEndDate = SubEndDate;
                        login.Flag                = FreeTrail;
                        gc.db.SCL_Login.Add(login);
                        int m = gc.db.SaveChanges();
                        if (m > 0 && x > 0)
                        {
                            Elasticmail.SendEmail(UserFormData.company_email, "Leads Account Details", body, "", "*****@*****.**", "Leads", "");

                            tran.Commit();
                            dic.Add("success", "success");
                        }
                        else
                        {
                            tran.Rollback();
                            dic.Add("Error", "Error");
                        }
                    }

                    else
                    {
                        dic.Add("error", "No results found!");
                    }
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    tran.Rollback();
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    dic.Add("error", raise.Message);
                }
            }
            return(dic);
        }