public ActionResult ConfirmAccount(string token)
 {
     try
     {
         var db = new TSS_Sql_Entities();
         if (token != null && token != "")
         {
             var checkToken = db.ContactConfirmations.FirstOrDefault(s => s.ConfirmationToken == token);
             if (checkToken != null)
             {
                 var datetimeCheck = DateTime.Compare(Convert.ToDateTime(checkToken.TokenExpiryTime), DateTime.Now);
                 if (datetimeCheck > 0)
                 {
                     checkToken.ConfirmationStatusId = 1;
                     db.SaveChanges();
                     ViewBag.Token = token;
                     return(View());
                 }
                 else
                 {
                     checkToken.ConfirmationStatusId = 4;
                     db.SaveChanges();
                     return(RedirectToAction("TokenExpired"));
                 }
             }
         }
         return(RedirectToAction("TokenNotFound"));
     }
     catch (Exception ex)
     {
         ExceptionHandlerController.infoMessage(ex.Message);
         ExceptionHandlerController.writeErrorLog(ex);
         return(RedirectToAction("TokenNotFound"));
     }
 }
Exemplo n.º 2
0
        public JsonResult SendTimeSheetLink(int id, string email, int checkUser = 0)
        {
            var db        = new TSS_Sql_Entities();
            var timesheet = db.Timesheets.Find(id);

            //var customerId = timesheet.Customer_Id_Generic;
            timesheet.Status_id = 2;
            db.SaveChanges();
            var user = db.AspNetUsers.FirstOrDefault(s => s.Email == email);

            if (user == null && checkUser == 0)
            {
                return(Json("Customer Doesn't Exists", JsonRequestBehavior.AllowGet));
            }

            try
            {
                var      fromAddress  = new MailAddress(SenderEmailId, "Total Staffing Solution");
                var      toAddress    = new MailAddress(email, email);
                string   fromPassword = SenderEmailPassword;
                string   subject      = "Total Staffing Solution: New Timesheet";
                DateTime saturday     = DateTime.Now.AddDays(6 - Convert.ToDouble(DateTime.Now.DayOfWeek));
                string   dateString   = String.Format("{0:MM/dd/yyyy}", saturday);
                string   body         = "<b>Hello " + email + "!</b><br />Below you'll find the link to your timesheets for the upcoming week. Please enter the hours worked for the employees listed and return to us by " + dateString + ".<br /><br /><a href='"
                                        + TSSLiveSiteURL + "/Timesheets/TimeSheetDetails/" + id + "'>Timesheet Link</a> <br />Thanks for joining and have a great day! <br />Total Staffing Solutions";

                var smtp = new SmtpClient
                {
                    Host           = SenderEmailHost,
                    Port           = SenderEmailPort,
                    EnableSsl      = false,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                    Timeout        = 20000
                };
                using (var message = new MailMessage(fromAddress, toAddress)
                {
                    IsBodyHtml = true,
                    Subject = subject,
                    Body = body,
                })
                {
                    //message.CC.Add("*****@*****.**");
                    ////message.CC.Add("*****@*****.**");
                    smtp.Send(message);
                }

                return(Json("Link Sent successfully", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);
                return(Json("Something Went wrong..!", JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 3
0
        public bool UpdateEmployees()
        {
            try
            {
                TSSWebServiceReference.VFPWebServiceSoapClient srvDBObj = new TSSWebServiceReference.VFPWebServiceSoapClient();
                var employeesList = srvDBObj.UpdateUsersData();
                var db            = new TSS_Sql_Entities();

                foreach (var item in employeesList)
                {
                    var empCheck = db.Employees.FirstOrDefault(s => s.First_name == item.Emcfname && s.Last_name == item.Emclname);
                    if (empCheck == null && Convert.ToInt32(empCheck.User_id) != Convert.ToInt32(item.Emcempid))
                    {
                        var employeeObj = new TotalStaffingSolutions.Models.Employee();
                        employeeObj.User_id        = Convert.ToInt32(item.Emcempid);
                        employeeObj.First_name     = item.Emcfname;
                        employeeObj.Last_name      = item.Emclname;
                        employeeObj.Middle_name    = item.Emcmname;
                        employeeObj.Created_at     = DateTime.Now;
                        employeeObj.Address1       = item.Emcaddr1;
                        employeeObj.Address2       = item.Emcaddr2;
                        employeeObj.City           = item.Emccity;
                        employeeObj.State          = item.Emcstate;
                        employeeObj.ZipCode        = item.Emczipcode;
                        employeeObj.Country        = item.Emccountry;
                        employeeObj.Marital_status = item.Emcmarital;
                        employeeObj.Gender         = item.Emcsex;
                        //employeeObj.DateOfBirth = Convert.ToDateTime(item.Emtbirth);
                        //employeeObj.Hire = Convert.ToDateTime(item.Emthire);
                        //employeeObj.ReHire = Convert.ToDateTime(item.Emtrehire);
                        employeeObj.EmployeeType    = item.Emcemptype;
                        employeeObj.ENTITY_ADDED_AT = DateTime.Now;
                        employeeObj.Updated_at      = DateTime.Now;

                        db.Employees.Add(employeeObj);
                        db.SaveChanges();
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);

                return(false);
            }
        }
Exemplo n.º 4
0
        public bool UpdateCustomers()
        {
            try
            {
                TSSWebServiceReference.VFPWebServiceSoapClient srvDBObj = new TSSWebServiceReference.VFPWebServiceSoapClient();
                var usersList = srvDBObj.UpdateCustomersData();
                var db        = new TSS_Sql_Entities();

                foreach (var item in usersList)
                {
                    var custCheck = db.Customers.FirstOrDefault(s => s.Customer_id == item.Cuccustid && s.Name == item.Cucname);
                    if (custCheck == null)
                    {
                        var userobj = new TotalStaffingSolutions.Models.Customer();
                        userobj.Name          = item.Cucname;
                        userobj.Customer_id   = item.Cuccustid;
                        userobj.Address1      = item.Cucaddr1;
                        userobj.Address2      = item.Cucaddr2;
                        userobj.City          = item.Cuccity;
                        userobj.State         = item.Cucstate;
                        userobj.CustomerAdded = DateTime.Now;
                        userobj.ZipCode       = item.Cuczipcode;
                        userobj.Country       = item.Cuccountry;
                        userobj.Created_at    = DateTime.Now;
                        //userobj.PhoneNumber = item.Cucpono;
                        userobj.Status          = item.Cucstatus;
                        userobj.ENTITY_ADDED_AT = DateTime.Now;
                        db.Customers.Add(userobj);
                        db.SaveChanges();
                        var ponoObj = new Po_Numbers();
                        ponoObj.ClientId          = userobj.Id;
                        ponoObj.Client_Generic_Id = userobj.Customer_id;
                        ponoObj.PoNumber          = item.Cucpono;
                        db.Po_Numbers.Add(ponoObj);
                        db.SaveChanges();
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);

                return(false);
            }
        }
Exemplo n.º 5
0
        public ActionResult TimeSheetsByBranch(int?id = 0)  //IMPORTANT UPDATE ALL FOLLOWING METHODS (Dashboard, TimeSheetsByBranch, TimeSheetsByClient, Timesheetsbyperiod)
        {
            try
            {
                if (id > 0)
                {
                    var db = new TSS_Sql_Entities();

                    List <Branch> bl = db.Branches.ToList();
                    Branch        b  = new Branch();
                    b.Id   = 0;
                    b.Name = "Select Branch";
                    bl.Add(b);
                    var a          = bl.OrderBy(s => s.Id);
                    var branchlist = new SelectList(a, "Id", "Name");
                    ViewBag.BranchsList = branchlist;
                    var timesheets = db.Timesheets.Where(s => s.Customer.Branch_id == id).ToList();
                    ViewBag.SelectedBranchId = id;
                    List <Customer> cl = db.Customers.ToList();
                    Customer        c  = new Customer();
                    c.Id   = 0;
                    c.Name = "Select Client";
                    cl.Add(c);
                    var orderedClients = cl.OrderBy(s => s.Id);
                    var clientlist     = new SelectList(orderedClients, "Id", "Name");
                    ViewBag.ClientsList = clientlist;

                    ViewBag.SelectedClientId = null;
                    return(View(timesheets));
                }
                else
                {
                    return(RedirectToAction("Dashboard"));
                }
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);
            }
            var list = new List <Timesheet>();

            return(View(list));
        }
Exemplo n.º 6
0
        public ActionResult Dashboard1() //IMPORTANT UPDATE ALL FOLLOWING METHODS (Dashboard, TimeSheetsByBranch, TimeSheetsByClient, Timesheetsbyperiod)
        {
            try
            {
                var           db = new TSS_Sql_Entities();
                List <Branch> bl = db.Branches.ToList();
                Branch        b  = new Branch();
                b.Id   = 0;
                b.Name = "Select Branch";
                bl.Add(b);
                var orderedbranches = bl.OrderBy(s => s.Id);
                var branchlist      = new SelectList(orderedbranches, "Id", "Name");
                ViewBag.BranchsList = branchlist;

                List <Customer> cl = db.Customers.ToList();
                Customer        c  = new Customer();
                c.Id   = 0;
                c.Name = "Select Client";
                cl.Add(c);
                var orderedClients = cl.OrderBy(s => s.Id);
                var clientlist     = new SelectList(orderedClients, "Id", "Name");
                ViewBag.ClientsList = clientlist;

                ViewBag.SelectedBranchId = "";
                ViewBag.SelectedClientId = "";

                //ViewBag.RejectedTimeSheets = db.RejectedTimesheets.ToList();

                return(View(db.Timesheets.ToList()));
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);
            }
            var list = new List <Timesheet>();

            return(View(list));
        }
Exemplo n.º 7
0
        public bool Test()
        {
            try
            {
                var    fromAddress  = new MailAddress("*****@*****.**", "Total Staffing Solution");
                var    toAddress    = new MailAddress("*****@*****.**", "Saqib Abdullah Azhar");
                string fromPassword = SenderEmailPassword;
                string subject      = "Total Staffing Solution: Account Confirmation";
                string body         = "<b>Hi Saqib testing email</b>";

                var smtp = new SmtpClient
                {
                    Host           = "mail.viretechnologies.com",
                    Port           = SenderEmailPort,
                    EnableSsl      = false,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    Credentials    = new NetworkCredential("*****@*****.**", "P@ssw0rd1"),
                    Timeout        = 20000
                };
                using (var message = new MailMessage(fromAddress, toAddress)
                {
                    IsBodyHtml = true,
                    Subject = subject,
                    Body = body,
                })
                {
                    smtp.Send(message);
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);
                return(false);
            }
        }
        public JsonResult RejectTimeSheet(int timesheetId, string reason)
        {
            try
            {
                var db           = new TSS_Sql_Entities();
                var userid       = User.Identity.GetUserId();
                var user         = db.AspNetUsers.FirstOrDefault(s => s.Id == userid);
                var rejectionObj = new RejectedTimesheet();
                rejectionObj.TimeSheetId           = timesheetId;
                rejectionObj.RejectionReason       = reason;
                rejectionObj.RejectedAt            = DateTime.Now;
                rejectionObj.IsUpdatedOrDeleted    = false;
                rejectionObj.RejecetedByCustomerId = Convert.ToInt32(user.Customer_id);
                db.RejectedTimesheets.Add(rejectionObj);
                var timesheet = db.Timesheets.FirstOrDefault(s => s.Id == timesheetId);
                timesheet.Status_id = 4;
                db.SaveChanges();

                ///////////////////////////////////ADMIN EMAIL UPDATE/////////////////////////////////////
                #region ADMIN EMAIL UPDATE
                if (User.IsInRole("User"))
                {
                    try
                    {
                        var    AdminId      = timesheet.Created_By;
                        var    admin        = db.AspNetUsers.FirstOrDefault(s => s.Id == AdminId);
                        var    fromAddress  = new MailAddress(SenderEmailId, "Total Staffing Solution");
                        var    toAddress    = new MailAddress(admin.Email, admin.Email);
                        string fromPassword = SenderEmailPassword;
                        string subject      = "Total Staffing Solution: Timesheet Update";
                        string body         = "<b>Hello " + admin.UserName + "!</b><br />Client has Rejected the timesheet<br /> <a href='" + TSSLiveSiteURL + "/Timesheets/TimeSheetDetails/" + timesheet.Id + "'>Timesheet Link</a><br />";

                        var smtp = new SmtpClient
                        {
                            Host           = SenderEmailHost,
                            Port           = SenderEmailPort,
                            EnableSsl      = false,
                            DeliveryMethod = SmtpDeliveryMethod.Network,
                            Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                            Timeout        = 20000
                        };
                        using (var message = new MailMessage(fromAddress, toAddress)
                        {
                            IsBodyHtml = true,
                            Subject = subject,
                            Body = body,
                        })
                        {
                            message.CC.Add("*****@*****.**");
                            //message.CC.Add("*****@*****.**");
                            smtp.Send(message);
                        }
                        ///
                    }
                    catch (Exception ex)
                    {
                        ExceptionHandlerController.infoMessage(ex.Message);
                        ExceptionHandlerController.writeErrorLog(ex);
                    }
                }
                #endregion
                //////////////////////////////////////////////////////////////////////////////////////////
                return(Json("Rejected Successfully!", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);
                return(Json("Something went wrong", JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 9
0
        public ActionResult Dashboard(DateTime?start_date, DateTime?end_date, int?branch_id, int?client_id)     //IMPORTANT UPDATE ALL FOLLOWING METHODS (Dashboard, TimeSheetsByBranch, TimeSheetsByClient, Timesheetsbyperiod)
        {
            try
            {
                branch_id = (branch_id == 0) ? null : branch_id;
                client_id = (client_id == 0) ? null : client_id;

                var           db = new TSS_Sql_Entities();
                List <Branch> bl = db.Branches.ToList();
                Branch        b  = new Branch();
                b.Id   = 0;
                b.Name = "Select Branch";
                bl.Add(b);
                var orderedbranches = bl.OrderBy(s => s.Id);
                var branchlist      = new SelectList(orderedbranches, "Id", "Name");
                ViewBag.BranchsList = branchlist;

                List <Customer> cl = db.Customers.ToList();
                Customer        c  = new Customer();
                c.Id   = 0;
                c.Name = "Select Client";
                cl.Add(c);
                var orderedClients = cl.OrderBy(s => s.Id);
                var clientlist     = new SelectList(orderedClients, "Id", "Name");
                ViewBag.ClientsList = clientlist;
                List <Timesheet> timesheets = new List <Timesheet>();

                //ViewBag.RejectedTimeSheets = db.RejectedTimesheets.ToList();

                if (end_date != null && start_date != null && branch_id != null && client_id != null)
                {
                    timesheets = db.Timesheets.Where(s => s.End_date >= start_date && s.End_date <= end_date && s.Customer_id == client_id && s.Customer.Branch_id == branch_id).ToList();

                    ViewBag.SelectedBranchId = branch_id;
                    ViewBag.SelectedClientId = client_id;
                }
                else if (start_date != null && end_date != null && client_id != null)
                {
                    timesheets = db.Timesheets.Where(s => s.End_date >= start_date && s.End_date <= end_date && s.Customer_id == client_id).ToList();

                    ViewBag.SelectedBranchId = null;
                    ViewBag.SelectedClientId = client_id;
                }
                else if (branch_id != null && end_date != null && start_date != null)
                {
                    timesheets = db.Timesheets.Where(s => s.End_date >= start_date && s.End_date <= end_date && s.Customer.Branch_id == branch_id).ToList();

                    ViewBag.SelectedBranchId = branch_id;
                    ViewBag.SelectedClientId = null;
                }
                else if (branch_id != null && client_id != null)
                {
                    timesheets = db.Timesheets.Where(s => s.Customer.Branch_id == branch_id && s.Customer_id == client_id).ToList();
                    ViewBag.SelectedBranchId = branch_id;
                    ViewBag.SelectedClientId = client_id;
                }
                else if (end_date != null && start_date != null)
                {
                    timesheets = db.Timesheets.Where(s => s.End_date >= start_date && s.End_date <= end_date).ToList();
                    ViewBag.SelectedBranchId = null;
                    ViewBag.SelectedClientId = null;
                }
                else if (branch_id != null)
                {
                    timesheets = db.Timesheets.Where(s => s.Customer.Branch_id == branch_id).ToList();
                    ViewBag.SelectedBranchId = branch_id;
                    ViewBag.SelectedClientId = null;
                }
                else if (client_id != null)
                {
                    timesheets = db.Timesheets.Where(s => s.Customer_id == client_id).ToList();
                    ViewBag.SelectedBranchId = null;
                    ViewBag.SelectedClientId = client_id;
                }
                else
                {
                    timesheets = db.Timesheets.ToList();
                    ViewBag.SelectedBranchId = null;
                    ViewBag.SelectedClientId = null;
                }



                return(View("Dashboard", timesheets));
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);
            }
            var list = new List <Timesheet>();

            return(View(list));
        }
Exemplo n.º 10
0
        public ActionResult SendAccountEmail(int id)
        {
            var db = new TSS_Sql_Entities();

            var ConfirmationToken = Membership.GeneratePassword(10, 0);

            ConfirmationToken = Regex.Replace(ConfirmationToken, @"[^a-zA-Z0-9]", m => "9");
            var savedContactObj  = db.CustomerContacts.OrderByDescending(s => s.Id).FirstOrDefault(s => s.Id == id);
            var contactStatusObj = new ContactConfirmation();

            contactStatusObj.ContactId            = savedContactObj.Id;
            contactStatusObj.LastUpdate           = DateTime.Now;
            contactStatusObj.TokenCreationTime    = contactStatusObj.LastUpdate;
            contactStatusObj.TokenExpiryTime      = DateTime.Now.AddHours(24);
            contactStatusObj.ConfirmationToken    = ConfirmationToken;
            contactStatusObj.ConfirmationStatusId = 1;
            db.ContactConfirmations.Add(contactStatusObj);
            db.SaveChanges();
            try
            {
                var    fromAddress  = new MailAddress(SenderEmailId, "Total Staffing Solution");
                var    toAddress    = new MailAddress(savedContactObj.Contact_name, savedContactObj.Contact_name);
                string fromPassword = SenderEmailPassword;
                string subject      = "Total Staffing Solution: Account Confirmation";
                string body         = "<b>Hello " + savedContactObj.Email_id + "!</b><br />Someone has invited you to http://total-staffing.raisenit.com/, you can accept it through the link below.<br /> <a href='" + TSSLiveSiteURL + "/ClientDashboard/ConfirmAccount?token=" + ConfirmationToken + "'>Accept invitation</a><br /><small style='text-align:center;'>(If you don't want to accept the invitation, please ignore this email.Your account won't be created until you access the link above and set your password.<br/><b>This Link is active for next 24 hours, Please make sure to Enable your account before " + DateTime.Now.AddHours(24) + "</b>)</small>";

                var smtp = new SmtpClient
                {
                    Host           = SenderEmailHost,
                    Port           = SenderEmailPort,
                    EnableSsl      = false,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                    Timeout        = 20000
                };
                using (var message = new MailMessage(fromAddress, toAddress)
                {
                    IsBodyHtml = true,
                    Subject = subject,
                    Body = body,
                })
                {
                    //message.CC.Add("*****@*****.**");

                    smtp.Send(message);
                }
                ///
                var savedContactConfirmationObj = db.ContactConfirmations.OrderByDescending(s => s.Id).FirstOrDefault(s => s.ContactId == contactStatusObj.ContactId);
                savedContactConfirmationObj.ConfirmationStatusId = 2;
                savedContactConfirmationObj.LastUpdate           = DateTime.Now;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);
                var savedContactConfirmationObj = db.ContactConfirmations.OrderByDescending(s => s.Id).FirstOrDefault(s => s.ContactId == contactStatusObj.ContactId);
                savedContactConfirmationObj.ConfirmationStatusId = 4;
                savedContactConfirmationObj.LastUpdate           = DateTime.Now;
                db.SaveChanges();
            }

            var clientContactObj = db.CustomerContacts.FirstOrDefault(s => s.Id == id);
            var clientObject     = db.Customers.FirstOrDefault(s => s.Customer_id == clientContactObj.Customer_id);
            var previousURL      = System.Web.HttpContext.Current.Request.UrlReferrer;

            if (previousURL.LocalPath == "/TSSManage/Dashboard")
            {
                return(RedirectToAction("Dashboard", "TSSManage"));
            }
            else
            {
                return(RedirectToAction("ClientDetails", "TSSManage", new { clientObject.Id }));
            }
        }
Exemplo n.º 11
0
        public bool UpdateCustomerContacts()
        {
            try
            {
                TSSWebServiceReference.VFPWebServiceSoapClient srvDBObj = new TSSWebServiceReference.VFPWebServiceSoapClient();
                var contactsList = srvDBObj.UpdateCustomerContacts();
                var db           = new TSS_Sql_Entities();
                foreach (var item in contactsList)
                {
                    var contactCheck = db.CustomerContacts.FirstOrDefault(s => s.Customer_key == item.Ccccusmast && s.Contact_key == item.Ccccuscont);
                    if (contactCheck == null)
                    {
                        var contactObj = new TotalStaffingSolutions.Models.CustomerContact();
                        contactObj.Contact_code        = item.Ccccatcde;
                        contactObj.Contact_description = item.Ccccontcde;
                        contactObj.Contact_key         = item.Ccccuscont;
                        contactObj.Contact_name        = item.Ccccontact;
                        contactObj.Contact_notes       = item.Ccmnotes;
                        contactObj.Customer_id         = item.Customer_id;
                        contactObj.Customer_key        = item.Ccccusmast;
                        contactObj.Email_id            = item.Cccemail;
                        contactObj.Phone_1             = item.Cccphone1;
                        contactObj.Phone_2             = item.Cccphone2;
                        contactObj.Phone_3             = item.Cccphone3;
                        contactObj.ENTITY_ADDED_AT     = DateTime.Now;
                        db.CustomerContacts.Add(contactObj);
                        db.SaveChanges();

                        if (item.Cccemail != null && item.Cccemail != "")
                        {
                            var ConfirmationToken = Membership.GeneratePassword(10, 0);
                            ConfirmationToken = Regex.Replace(ConfirmationToken, @"[^a-zA-Z0-9]", m => "9");
                            var savedContactObj  = db.CustomerContacts.OrderByDescending(s => s.Id).FirstOrDefault(s => s.Customer_id == contactObj.Customer_id);
                            var contactStatusObj = new ContactConfirmation();
                            contactStatusObj.ContactId            = savedContactObj.Id;
                            contactStatusObj.LastUpdate           = DateTime.Now;
                            contactStatusObj.TokenCreationTime    = contactStatusObj.LastUpdate;
                            contactStatusObj.TokenExpiryTime      = DateTime.Now.AddHours(24);
                            contactStatusObj.ConfirmationToken    = ConfirmationToken;
                            contactStatusObj.ConfirmationStatusId = 1;
                            db.ContactConfirmations.Add(contactStatusObj);
                            db.SaveChanges();
                            try
                            {
                                var    fromAddress  = new MailAddress(SenderEmailId, "Total Staffing Solution");
                                var    toAddress    = new MailAddress(savedContactObj.Email_id, savedContactObj.Contact_name);
                                string fromPassword = SenderEmailPassword;
                                string subject      = "Total Staffing Solution: Account Confirmation";
                                string body         = "<b>Hi " + savedContactObj.Contact_name + "!</b><br />Please confirm your email by clicking on following link <br /> <a href='" + TSSLiveSiteURL + "/ClientDashboard/ConfirmAccount?token=" + ConfirmationToken + "'>Confirmation Link</a><br /><small style='text-align:center;'>(This Link is active for next 24 hours, Please make sure to Enable your account before " + DateTime.Now.AddHours(24) + ")</small>";

                                var smtp = new SmtpClient
                                {
                                    Host           = SenderEmailHost,
                                    Port           = SenderEmailPort,
                                    EnableSsl      = false,
                                    DeliveryMethod = SmtpDeliveryMethod.Network,
                                    Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                                    Timeout        = 20000
                                };
                                using (var message = new MailMessage(fromAddress, toAddress)
                                {
                                    IsBodyHtml = true,
                                    Subject = subject,
                                    Body = body,
                                })
                                {
                                    smtp.Send(message);
                                }
                                ///
                                var savedContactConfirmationObj = db.ContactConfirmations.OrderByDescending(s => s.Id).FirstOrDefault(s => s.ContactId == contactStatusObj.ContactId);
                                savedContactConfirmationObj.ConfirmationStatusId = 2;
                                savedContactConfirmationObj.LastUpdate           = DateTime.Now;
                                db.SaveChanges();
                            }
                            catch (Exception ex)
                            {
                                ExceptionHandlerController.infoMessage(ex.Message);
                                ExceptionHandlerController.writeErrorLog(ex);
                                var savedContactConfirmationObj = db.ContactConfirmations.OrderByDescending(s => s.Id).FirstOrDefault(s => s.ContactId == contactStatusObj.ContactId);
                                savedContactConfirmationObj.ConfirmationStatusId = 4;
                                savedContactConfirmationObj.LastUpdate           = DateTime.Now;
                                db.SaveChanges();
                            }
                        }
                    }
                }
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandlerController.infoMessage(ex.Message);
                ExceptionHandlerController.writeErrorLog(ex);
                return(false);
            }
        }