Example #1
0
        public ActionResult EditNewRoll(QuickEnrollment roll)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            //var Department = db.Master_Department.ToList();
            string ServerName     = AppValue.GetFromMailAddress("ServerName");
            var    DepartmentList = (from us in db.Departments

                                     select new
            {
                DepartmentId = us.DepartmentId,
                DepartmentName = us.DepartmentName
            }).OrderBy(o => o.DepartmentName).ToList();
            var GroupList = db.DepartmentGroups.Where(dg => dg.IsActive == true).Select(g => new
            {
                groupid   = g.GroupID,
                groupname = g.GroupName
            }).OrderBy(o => o.groupname).ToList();



            var EditQuickEnroll = db.QuickEnrolls.Where(q => q.QuickEnroll1 == roll.QuickEnroll).Select(r => r).FirstOrDefault();

            EditQuickEnroll.FirstName   = roll.FirstName;
            EditQuickEnroll.LastName    = roll.LastName;
            EditQuickEnroll.Address     = roll.Address;
            EditQuickEnroll.Location    = roll.Location;
            EditQuickEnroll.PhoneNumber = roll.PhoneNumber;
            //EditQuickEnroll.DateOfJoin = Convert.ToDateTime(roll.DateOfJoin);
            EditQuickEnroll.DateOfJoin = roll.DateOfJoin;
            EditQuickEnroll.BranchID   = roll.BranchName;
            EditQuickEnroll.GenderID   = roll.GenderID;
            EditQuickEnroll.RoleID     = (byte)roll.RollID;

            if (roll.DateOfBirth != DateTime.MinValue)
            {
                EditQuickEnroll.DateOfBirth = Convert.ToDateTime(roll.DateOfBirth);
            }
            // EditQuickEnroll.DateOfJoin = roll.DateOfJoin;
            // EditQuickEnroll.Experience = roll.Experience;
            EditQuickEnroll.PersonalMailAddress = roll.PersonalEmailAddress;

            EditQuickEnroll.DepartmentID = roll.DepartmentName;
            if (roll.DepartmentGroup != 0)
            {
                EditQuickEnroll.DepartmentGroup = roll.DepartmentGroup;
            }

            else
            {
                EditQuickEnroll.DepartmentGroup = null;
            }
            EditQuickEnroll.Comments   = roll.Comments;
            EditQuickEnroll.Experience = roll.Experience;


            db.SaveChanges();

            ViewBag.GroupID        = roll.DepartmentGroup;
            ViewBag.DepartmentId   = roll.DepartmentList;
            ViewBag.YearsList      = new SelectList(YearsList(), "YearId", "Year", roll.Experience);
            ViewBag.MonthList      = new SelectList(MonthsList(), "MonthId", "Month", roll.ExperienceMonth);
            ViewBag.GroupList      = new SelectList(GroupList, "ID", "GroupName", roll.DepartmentList);
            ViewBag.DepartmentList = new SelectList(DepartmentList, "ID", "DepartmentList", roll.DepartmentGroup);



            if (roll.QuickEnroll != null)
            {
                var check  = db.EmailTemplates.Where(x => x.TemplatePurpose == "EditEnroll").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "EditEnroll").Select(x => x.TemplatePath).FirstOrDefault();
                if ((check != null) && (check != 0))
                {
                    var objnewuser = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "EditEnroll")
                                      join q in db.EmailTemplates on p.EmailTemplateID equals q.EmailTemplateID
                                      select new DSRCManagementSystem.Models.Email
                    {
                        To = p.To,
                        CC = p.CC,
                        BCC = p.BCC,
                        Subject = p.Subject,
                        Template = q.TemplatePath
                    }).FirstOrDefault();
                    //var date = Convert.ToString(roll.DateOfJoin);
                    string Date1 = null;
                    if (roll.DateOfJoin != null)
                    {
                        string   Date  = Convert.ToString(roll.DateOfJoin);
                        DateTime jdate = (Convert.ToDateTime(Date));
                        Date1 = jdate.ToString("dd-MM-yyyy");
                    }

                    string editdate            = DateTime.Now.ToString("dd-MM-yyyy");
                    var    company             = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                    string TemplatePathnewuser = Server.MapPath(objnewuser.Template);
                    string EditEnrollhtml      = System.IO.File.ReadAllText(TemplatePathnewuser);

                    EditEnrollhtml = EditEnrollhtml.Replace("#Name", roll.FirstName + "  " + roll.LastName);
                    EditEnrollhtml = EditEnrollhtml.Replace("#JoiningDate", Date1);
                    EditEnrollhtml = EditEnrollhtml.Replace("#Experience", roll.Experience);
                    EditEnrollhtml = EditEnrollhtml.Replace("#Date", editdate);

                    EditEnrollhtml = EditEnrollhtml.Replace("#ServerName", ServerName);
                    EditEnrollhtml = EditEnrollhtml.Replace("#CompanyName", company);
                    if (objnewuser.To != "")
                    {
                        objnewuser.To = QuickEnrollController.GetUserEmailAddress(db, objnewuser.To);
                    }
                    if (objnewuser.CC != "")
                    {
                        objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.CC);
                    }
                    if (objnewuser.BCC != "")
                    {
                        // objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.BCC);
                    }

                    //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    var logo = CommonLogic.getLogoPath();
                    // string ServerName = WebConfigurationManager.AppSettings["SeverName"];

                    int    userId      = int.Parse(Session["UserID"].ToString());
                    var    userdetails = db.Users.FirstOrDefault(o => o.UserID == userId);
                    string MailID      = userdetails.EmailAddress;

                    if (ServerName != "http://*****:*****@dsrc.co.in");
                        //MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        // MailIds.Add("*****@*****.**");
                        //MailIds.Add("*****@*****.**");

                        string EmailAddress = "";

                        foreach (string maiil in MailIds)
                        {
                            EmailAddress += maiil + ",";
                        }

                        EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);


                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", EditEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", EditEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", EditEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", EditEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.ToString()));
                        });
                    }
                }

                else
                {
                    //  string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                    ExceptionHandlingController.TemplateMissing("EditEnroll", folder, ServerName);
                }
            }

            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult Delete(int Quickenrollid)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            string ServerName        = AppValue.GetFromMailAddress("ServerName");
            var    DeleteQuickEnroll = db.QuickEnrolls.Where(o => o.QuickEnroll1 == Quickenrollid).Select(o => o).FirstOrDefault();

            DeleteQuickEnroll.IsActive = false;
            db.SaveChanges();



            if (Quickenrollid != null)
            {
                var check  = db.EmailTemplates.Where(x => x.TemplatePurpose == "DeleteEnroll").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "DeleteEnroll").Select(x => x.TemplatePath).FirstOrDefault();
                if ((check != null) && (check != 0))
                {
                    var objnewuser = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "DeleteEnroll")
                                      join q in db.EmailTemplates on p.EmailTemplateID equals q.EmailTemplateID
                                      select new DSRCManagementSystem.Models.Email
                    {
                        To = p.To,
                        CC = p.CC,
                        BCC = p.BCC,
                        Subject = p.Subject,
                        Template = q.TemplatePath
                    }).FirstOrDefault();
                    //var date = Convert.ToString(roll.DateOfJoin);

                    var Date1 = (from p in db.QuickEnrolls.Where(p => p.QuickEnroll1 == Quickenrollid)
                                 select(p.DateOfJoin)).FirstOrDefault();

                    var Name = (from p in db.QuickEnrolls.Where(p => p.QuickEnroll1 == Quickenrollid)
                                select(p.FirstName)).FirstOrDefault();

                    var Name1 = (from p in db.QuickEnrolls.Where(p => p.QuickEnroll1 == Quickenrollid)
                                 select(p.LastName)).FirstOrDefault();

                    var Exp = (from p in db.QuickEnrolls.Where(p => p.QuickEnroll1 == Quickenrollid)
                               select(p.Experience)).FirstOrDefault();

                    string   Exp1                = Convert.ToString(Exp);
                    DateTime endate              = (Convert.ToDateTime(Date1));
                    string   Date                = endate.ToString("dd-MM-yyyy");
                    string   Deldate             = DateTime.Now.ToString("dd-MM-yyyy");
                    var      company             = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                    string   TemplatePathnewuser = Server.MapPath(objnewuser.Template);
                    string   DeleteEnrollhtml    = System.IO.File.ReadAllText(TemplatePathnewuser);

                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#Name", Name + "  " + Name1);
                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#JoiningDate", Date);
                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#Experience", Exp1);
                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#Date", Deldate);

                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#ServerName", ServerName);
                    DeleteEnrollhtml = DeleteEnrollhtml.Replace("#CompanyName", company);
                    if (objnewuser.To != "")
                    {
                        objnewuser.To = QuickEnrollController.GetUserEmailAddress(db, objnewuser.To);
                    }
                    if (objnewuser.CC != "")
                    {
                        objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.CC);
                    }
                    if (objnewuser.BCC != "")
                    {
                        // objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.BCC);
                    }

                    //var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    var logo = CommonLogic.getLogoPath();
                    //string ServerName = WebConfigurationManager.AppSettings["SeverName"];

                    int    userId      = int.Parse(Session["UserID"].ToString());
                    var    userdetails = db.Users.FirstOrDefault(o => o.UserID == userId);
                    string MailID      = userdetails.EmailAddress;

                    if (ServerName != "http://*****:*****@dsrc.co.in");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");

                        string EmailAddress = "";

                        foreach (string maiil in MailIds)
                        {
                            EmailAddress += maiil + ",";
                        }

                        EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);


                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", DeleteEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", DeleteEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", DeleteEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", DeleteEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.ToString()));
                        });
                    }
                }

                else
                {
                    //string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                    ExceptionHandlingController.TemplateMissing("DeleteEnroll", folder, ServerName);
                }
            }


            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public ActionResult AddNewRoll(QuickEnrollment role)
        {
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
            string ServerName = AppValue.GetFromMailAddress("ServerName");
            string exp        = "--";
            string Date       = null;
            string Date1      = null;
            //DateTime todate = (Convert.ToDateTime(role.DateOfJoin));  // added
            var AddRoles = db.QuickEnrolls.CreateObject();

            AddRoles.FirstName   = role.FirstName;
            AddRoles.LastName    = role.LastName;
            AddRoles.Address     = role.Address;
            AddRoles.Location    = role.Location;
            AddRoles.PhoneNumber = role.PhoneNumber;
            //if (role.DateOfBirth != DateTime.MinValue)
            //{
            //    AddRoles.DateOfBirth = Convert.ToDateTime(role.DateOfBirth);
            //}
            AddRoles.BranchID = role.BranchID;
            if (role.DateOfJoin != null)
            {
                AddRoles.DateOfJoin = Convert.ToDateTime(role.DateOfJoin);
                DateTime todate = (Convert.ToDateTime(role.DateOfJoin));
                Date = todate.ToString("dd-MM-yyyy");
            }
            if (role.DateOfEnquiry != null)
            {
                AddRoles.DateOfEnquiry = Convert.ToDateTime(role.DateOfEnquiry);
                DateTime endate = (Convert.ToDateTime(role.DateOfEnquiry));
                Date1 = endate.ToString("dd-MM-yyyy");
            }
            //added on 9/9
            if (role.Experience != "undefined.undefined")
            {
                exp = role.Experience;
            }
            else
            {
                exp = "0";
            }
            //ends
            AddRoles.Experience          = role.Experience;
            AddRoles.PersonalMailAddress = role.PersonalEmailAddress;
            AddRoles.DepartmentID        = role.DepartmentName;
            AddRoles.RoleID        = (byte)role.RollID;
            AddRoles.GenderID      = role.GenderID;
            AddRoles.DateOfEnquiry = role.DateOfEnquiry;
            if (role.DepartmentGroup != 0)
            {
                AddRoles.DepartmentGroup = role.DepartmentGroup;
            }
            AddRoles.Comments   = role.Comments;
            AddRoles.Experience = role.Experience;
            AddRoles.IsActive   = true;
            db.QuickEnrolls.AddObject(AddRoles);
            db.SaveChanges();

            if (role.QuickEnroll != null)
            {
                var checks = db.EmailTemplates.Where(x => x.TemplatePurpose == "AddEnroll").Select(o => o.EmailTemplateID).FirstOrDefault();
                var folder = db.EmailTemplates.Where(o => o.TemplatePurpose == "AddEnroll").Select(x => x.TemplatePath).FirstOrDefault();
                if ((checks != null) && (checks != 0))
                {
                    var objnewuser = (from p in db.EmailPurposes.Where(x => x.EmailPurposeName == "AddEnroll")
                                      join q in db.EmailTemplates on p.EmailTemplateID equals q.EmailTemplateID
                                      select new DSRCManagementSystem.Models.Email
                    {
                        To = p.To,
                        CC = p.CC,
                        BCC = p.BCC,
                        Subject = p.Subject,
                        Template = q.TemplatePath
                    }).FirstOrDefault();

                    var    company             = db.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault();
                    string TemplatePathnewuser = Server.MapPath(objnewuser.Template);
                    string AddEnrollhtml       = System.IO.File.ReadAllText(TemplatePathnewuser);

                    AddEnrollhtml = AddEnrollhtml.Replace("#Name", role.FirstName + "  " + role.LastName);
                    AddEnrollhtml = AddEnrollhtml.Replace("#JoiningDate", Date);
                    AddEnrollhtml = AddEnrollhtml.Replace("#Experience", exp); //role.Experience);
                    AddEnrollhtml = AddEnrollhtml.Replace("#Date", Date);

                    AddEnrollhtml = AddEnrollhtml.Replace("#ServerName", ServerName);
                    AddEnrollhtml = AddEnrollhtml.Replace("#CompanyName", company);
                    if (objnewuser.To != "")
                    {
                        objnewuser.To = QuickEnrollController.GetUserEmailAddress(db, objnewuser.To);
                    }
                    if (objnewuser.CC != "")
                    {
                        objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.CC);
                    }
                    if (objnewuser.BCC != "")
                    {
                        // objnewuser.BCC = QuickEnrollController.GetUserEmailAddress(db, objnewuser.BCC);
                    }

                    // var logo = db.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault();
                    var logo = CommonLogic.getLogoPath();
                    //string ServerName = WebConfigurationManager.AppSettings["SeverName"];

                    int    userId      = int.Parse(Session["UserID"].ToString());
                    var    userdetails = db.Users.FirstOrDefault(o => o.UserID == userId);
                    string MailID      = userdetails.EmailAddress;

                    if (ServerName != "http://*****:*****@dsrc.co.in");
                        // MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        MailIds.Add("*****@*****.**");
                        //MailIds.Add("*****@*****.**");
                        // MailIds.Add("*****@*****.**");

                        string EmailAddress = "";

                        foreach (string maiil in MailIds)
                        {
                            EmailAddress += maiil + ",";
                        }

                        EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1);


                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", AddEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject + " - Test Mail Please Ignore", "", AddEnrollhtml + " - Testing Plaese ignore", "*****@*****.**", EmailAddress, Server.MapPath(logo.ToString()));
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            // DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", AddEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.AppValue.ToString()));
                            DsrcMailSystem.MailSender.SendMail(null, objnewuser.Subject, "", AddEnrollhtml, "*****@*****.**", MailID, Server.MapPath(logo.ToString()));
                        });
                    }
                }
                else
                {
                    // string ServerName = WebConfigurationManager.AppSettings["SeverName"];
                    ExceptionHandlingController.TemplateMissing("AddEnroll", folder, ServerName);
                }
            }
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }