public int CreateConnection(ConnectionProperty connection)
        {
            if (connection != null)
            {
                _dbContext.ConnectionProperties.Add(connection);
            }

            return(_dbContext.SaveChanges());
        }
        public ActionResult ForgotPassword(string email)
        {
            string message = "";
            bool   status  = false;

            using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext())
            {
                var account = dc.Users.FirstOrDefault(a => a.Email == email);
                if (account != null)
                {
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.Email, resetCode, "ResetPassword");
                    account.ResetPasswordCode = resetCode;
                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset password link has been sent to your email id.";
                }
                else
                {
                    message = "Account not found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
Example #3
0
        public int AddOrEdit(NewsletterSubscriber newsletterSubscriber)
        {
            if (newsletterSubscriber.NewsletterSubscriberId == 0)
            {
                newsletterSubscriber.MachineIP        = HttpContext.Current.Request.UserHostAddress;
                newsletterSubscriber.SubscriptionDate = DateTime.Now;
                _dbContext.NewsletterSubscribers.Add(newsletterSubscriber);
            }
            else
            {
                newsletterSubscriber.MachineIP               = HttpContext.Current.Request.UserHostAddress;
                newsletterSubscriber.SubscriptionDate        = DateTime.Now;
                _dbContext.Entry(newsletterSubscriber).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
 public int CreateUser(ChatUser chatUser)
 {
     if (chatUser != null)
     {
         _dbContext.ChatUsers.Add(chatUser);
     }
     return(_dbContext.SaveChanges());
 }
Example #5
0
        public int AddOrEdit(NewsletterMail newsletterMail)
        {
            if (newsletterMail.NewsletterMailId == 0)
            {
                newsletterMail.CreatedBy   = "Ayesha";
                newsletterMail.CreatedDate = DateTime.Now;
                _dbContext.NewsletterMails.Add(newsletterMail);
            }
            else
            {
                newsletterMail.UpdatedBy               = "Ayesha";
                newsletterMail.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(newsletterMail).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #6
0
        public int AddOrEdit(OnlineUserFeedBackDetail onlineUserFeedBackDetail)
        {
            if (onlineUserFeedBackDetail.UserFeedBackId == 0)
            {
                onlineUserFeedBackDetail.MachineIP   = HttpContext.Current.Request.UserHostAddress;
                onlineUserFeedBackDetail.CreatedDate = DateTime.Now;
                _dbContext.OnlineUserFeedBackDetails.Add(onlineUserFeedBackDetail);
            }
            else
            {
                onlineUserFeedBackDetail.MachineIP               = HttpContext.Current.Request.UserHostAddress;
                onlineUserFeedBackDetail.CreatedDate             = DateTime.Now;
                _dbContext.Entry(onlineUserFeedBackDetail).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public ActionResult Login(UserLogin login, string ReturnUrl = "")
        {
            string message = "";

            using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext())
            {
                var v = dc.Users.FirstOrDefault(a => a.Email == login.Email);
                if (v != null)
                {
                    if (!v.IsEmailVerified)
                    {
                        ViewBag.Message = "Please verify your email first";
                        return(View());
                    }
                    if (String.CompareOrdinal(Crypto.Hash(login.Password), v.Password) == 0)
                    {
                        int    timeout   = login.RememberMe ? 525600 : 20; // 525600 min = 1 year
                        var    ticket    = new FormsAuthenticationTicket(login.Email, login.RememberMe, timeout);
                        string encrypted = FormsAuthentication.Encrypt(ticket);
                        var    cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
                        cookie.Expires  = DateTime.Now.AddMinutes(timeout);
                        cookie.HttpOnly = true;
                        Response.Cookies.Add(cookie);

                        Session["User"]     = login.Email;
                        Session["UserName"] = v.UserName;

                        #region AddLogin info
                        var logininfo = new LoginInfo();
                        logininfo.UserId    = v.UserId;
                        logininfo.LogInTime = DateTime.Now;
                        logininfo.LoginIp   = Request.UserHostAddress;
                        dc.LoginInfoes.Add(logininfo);
                        dc.SaveChanges();
                        #endregion

                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Registration"));
                        }
                    }
                    else
                    {
                        message = "Invalid credential provided";
                    }
                }
                else
                {
                    message = "Invalid credential provided";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
        public int AddOrEdit(BlogCategory blogCategory)
        {
            if (blogCategory.BlogCategoryId == 0)
            {
                blogCategory.CreatedDate = DateTime.Now;
                blogCategory.UpdatedDate = DateTime.Now;
                blogCategory.CreatedBy   = 1;
                blogCategory.UpdatedBy   = 1;
                _dbContext.BlogCategories.Add(blogCategory);
            }
            else
            {
                blogCategory.UpdatedBy               = 1;
                blogCategory.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(blogCategory).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public int AddOrEdit(Employee employee)
        {
            if (employee.EmployeeId == 0)
            {
                employee.CreatedDate = DateTime.Now;
                employee.UpdatedDate = DateTime.Now;
                employee.CreatedBy   = 1;
                employee.UpdatedBy   = 1;
                _dbContext.Employees.Add(employee);
            }
            else
            {
                employee.UpdatedBy               = 1;
                employee.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(employee).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public int AddOrEdit(SocialAccountType socialAccountType)
        {
            if (socialAccountType.SocialAccountTypeId == 0)
            {
                socialAccountType.CreatedDate = DateTime.Now;
                socialAccountType.UpdatedDate = DateTime.Now;
                socialAccountType.CreatedBy   = 1;
                socialAccountType.UpdatedBy   = 1;
                _dbContext.SocialAccountTypes.Add(socialAccountType);
            }
            else
            {
                socialAccountType.UpdatedBy               = 1;
                socialAccountType.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(socialAccountType).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #11
0
        public int AddOrEdit(Designation designation)
        {
            if (designation.DesignationId == 0)
            {
                designation.CreatedDate = DateTime.Now;
                designation.UpdatedDate = DateTime.Now;
                designation.CreatedBy   = 1;
                designation.UpdatedBy   = 1;
                _dbContext.Designations.Add(designation);
            }
            else
            {
                designation.UpdatedBy               = 1;
                designation.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(designation).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #12
0
        public int AddOrEdit(FeatureDetail featureDetail)
        {
            if (featureDetail.FeatureDetailId == 0)
            {
                featureDetail.CreatedDate = DateTime.Now;
                featureDetail.UpdatedDate = DateTime.Now;
                featureDetail.CreatedBy   = 1;
                featureDetail.UpdatedBy   = 1;
                _dbContext.FeatureDetails.Add(featureDetail);
            }
            else
            {
                featureDetail.UpdatedBy               = 1;
                featureDetail.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(featureDetail).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #13
0
        public int AddOrEdit(Blog blog)
        {
            if (blog.BlogId == 0)
            {
                blog.CreatedDate = DateTime.Now;
                blog.UpdatedDate = DateTime.Now;
                blog.CreatedBy   = 1;
                blog.UpdatedBy   = 1;
                _dbContext.Blogs.Add(blog);
            }
            else
            {
                blog.UpdatedBy               = 1;
                blog.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(blog).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #14
0
        public int AddOrEdit(Service service)
        {
            if (service.ServiceId == 0)
            {
                service.CreatedDate = DateTime.Now;
                service.UpdatedDate = DateTime.Now;
                service.CreatedBy   = 1;
                service.UpdatedBy   = 1;
                _dbContext.Services.Add(service);
            }
            else
            {
                service.UpdatedBy               = 1;
                service.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(service).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #15
0
        public int AddOrEdit(ProductCategory productCategory)
        {
            if (productCategory.ProductCategoryId == 0)
            {
                productCategory.CreatedDate = DateTime.Now;
                productCategory.UpdatedDate = DateTime.Now;
                productCategory.CreatedBy   = 1;
                productCategory.UpdatedBy   = 1;
                _dbContext.ProductCategories.Add(productCategory);
            }
            else
            {
                productCategory.UpdatedBy               = 1;
                productCategory.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(productCategory).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #16
0
        public int AddOrEdit(PricingDetail pricingDetail)
        {
            if (pricingDetail.PricingDetailID == 0)
            {
                pricingDetail.CreatedDate = DateTime.Now;
                pricingDetail.UpdatedDate = DateTime.Now;
                pricingDetail.CreatedBy   = 1;
                pricingDetail.UpdatedBy   = 1;
                _dbContext.PricingDetails.Add(pricingDetail);
            }
            else
            {
                pricingDetail.UpdatedBy               = 1;
                pricingDetail.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(pricingDetail).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public int AddOrEdit(IconList iconList)
        {
            if (iconList.IconId == 0)
            {
                iconList.CreatedDate = DateTime.Now;
                iconList.UpdatedDate = DateTime.Now;
                iconList.CreatedBy   = 1;
                iconList.UpdatedBy   = 1;
                _dbContext.IconLists.Add(iconList);
            }
            else
            {
                iconList.UpdatedBy               = 1;
                iconList.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(iconList).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #18
0
        public int AddOrEdit(FeatureHeader featureHeader)
        {
            if (featureHeader.FeatureHeaderId == 0)
            {
                featureHeader.CreatedDate = DateTime.Now;
                featureHeader.UpdatedDate = DateTime.Now;
                featureHeader.CreatedBy   = 1;
                featureHeader.UpdatedBy   = 1;
                _dbContext.FeatureHeaders.Add(featureHeader);
            }
            else
            {
                featureHeader.UpdatedBy               = 1;
                featureHeader.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(featureHeader).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public int AddOrEdit(HomeBanner homeBanner)
        {
            if (homeBanner.HomeBannerId == 0)
            {
                homeBanner.CreatedDate = DateTime.Now;
                homeBanner.UpdatedDate = DateTime.Now;
                homeBanner.CreatedBy   = 1;
                homeBanner.UpdatedBy   = 1;
                _dbContext.HomeBanners.Add(homeBanner);
            }
            else
            {
                homeBanner.UpdatedBy               = 1;
                homeBanner.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(homeBanner).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #20
0
        public int AddOrEdit(ClientList clientList)
        {
            if (clientList.ClientID == 0)
            {
                clientList.CreatedDate = DateTime.Now;
                clientList.UpdatedDate = DateTime.Now;
                clientList.CreatedBy   = 1;
                clientList.UpdatedBy   = 1;
                _dbContext.ClientLists.Add(clientList);
            }
            else
            {
                clientList.UpdatedBy               = 1;
                clientList.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(clientList).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public int AddOrEdit(SoftwareCategory softwareCategory)
        {
            if (softwareCategory.SoftwareCategoryId == 0)
            {
                softwareCategory.CreatedDate = DateTime.Now;
                softwareCategory.UpdatedDate = DateTime.Now;
                softwareCategory.CreatedBy   = 1;
                softwareCategory.UpdatedBy   = 1;
                _dbContext.SoftwareCategories.Add(softwareCategory);
            }
            else
            {
                softwareCategory.UpdatedBy               = 1;
                softwareCategory.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(softwareCategory).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #22
0
        public int AddOrEdit(CompanyDetail companyDetail)
        {
            if (companyDetail.CompanyId == 0)
            {
                companyDetail.CreatedDate = DateTime.Now;
                companyDetail.UpdatedDate = DateTime.Now;
                companyDetail.CreatedBy   = 1;
                companyDetail.UpdatedBy   = 1;
                _dbContext.CompanyDetails.Add(companyDetail);
            }
            else
            {
                companyDetail.UpdatedBy               = 1;
                companyDetail.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(companyDetail).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
Example #23
0
        public int AddOrEdit(PricingTableType pricingTableType)
        {
            if (pricingTableType.PricingTableTypeID == 0)
            {
                pricingTableType.CreatedDate = DateTime.Now;
                pricingTableType.UpdatedDate = DateTime.Now;
                pricingTableType.CreatedBy   = 1;
                pricingTableType.UpdatedBy   = 1;
                _dbContext.PricingTableTypes.Add(pricingTableType);
            }
            else
            {
                pricingTableType.UpdatedBy               = 1;
                pricingTableType.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(pricingTableType).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public int AddOrEdit(FAQ FAQ)
        {
            if (FAQ.FAQId == 0)
            {
                FAQ.CreatedDate = DateTime.Now;
                FAQ.UpdatedDate = DateTime.Now;
                FAQ.CreatedBy   = 1;
                FAQ.UpdatedBy   = 1;
                _dbContext.FAQs.Add(FAQ);
            }
            else
            {
                FAQ.UpdatedBy               = 1;
                FAQ.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(FAQ).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User user)
        {
            bool   Status  = false;
            string message = "";

            //
            // Model Validation
            if (ModelState.IsValid)
            {
                #region //Email is already Exist
                var isExist = IsEmailExist(user.Email);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email already exist");
                    return(View(user));
                }
                #endregion

                #region Generate Activation Code
                user.ActivationCode = Guid.NewGuid().ToString();
                #endregion

                #region  Password Hashing
                user.Password = Crypto.Hash(user.Password);
                #endregion
                user.IsEmailVerified = false;

                user.RegistrationDate = DateTime.Now;

                #region Save to Database
                using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext())
                {
                    dc.Users.Add(user);
                    dc.SaveChanges();

                    //Send Email to User
                    SendVerificationLinkEmail(user.Email, user.ActivationCode.ToString());
                    message = "Registration successfully done. Account activation link " +
                              " has been sent to your email id:" + user.Email;
                    Status = true;
                }
                #endregion
            }
            else
            {
                message = "Invalid Request";
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(user));
        }
        public int AddOrEdit(SmtpHost smtpHost)
        {
            if (smtpHost.SmtpHostId == 0)
            {
                string password = new EncryptionDecryption().Encrypt(smtpHost.UserName, smtpHost.Password);
                smtpHost.Password = password;

                smtpHost.CreatedBy   = "Ayesha";
                smtpHost.CreatedDate = DateTime.Now;
                _dbContext.SmtpHosts.Add(smtpHost);
            }
            else
            {
                string password = new EncryptionDecryption().Encrypt(smtpHost.UserName, smtpHost.Password);
                smtpHost.Password = password;

                smtpHost.UpdatedBy               = "Ayesha";
                smtpHost.UpdatedDate             = DateTime.Now;
                _dbContext.Entry(smtpHost).State = EntityState.Modified;
            }

            return(_dbContext.SaveChanges());
        }
        public ActionResult RegisterUser(ChatUser chatUser)
        {
            if (chatUser != null)
            {
                ChatUser user = new ChatUser();
                user.ChatUserName = chatUser.ChatUserName;

                using (AlphasoftWebsiteContext db = new AlphasoftWebsiteContext())
                {
                    db.ChatUsers.Add(user);
                    db.SaveChanges();
                }

                Session["UserName"] = chatUser.ChatUserName;
                return(View());
            }
            return(View());
        }
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext())
            {
                var v = dc.Users.FirstOrDefault(a => a.ActivationCode == new Guid(id).ToString());
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }
        public ActionResult ResetPassword(ResetPassword model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (AlphasoftWebsiteContext dc = new AlphasoftWebsiteContext())
                {
                    var user = dc.Users.FirstOrDefault(a => a.ResetPasswordCode == model.ResetCode);
                    if (user != null)
                    {
                        user.Password          = Crypto.Hash(model.NewPassword);
                        user.ResetPasswordCode = "";

                        #region Add ResetPassword info
                        var resetpassword = new ResetPassword();
                        resetpassword.UserId      = user.UserId;
                        resetpassword.ResetCode   = model.ResetCode;
                        resetpassword.NewPassword = user.Password;
                        resetpassword.ResetTime   = DateTime.Now;
                        dc.ResetPasswords.Add(resetpassword);
                        #endregion

                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "New password updated successfully";
                    }
                }
            }
            else
            {
                message = "Something invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
        public ActionResult ViewAll(FormCollection formCollection, int NewsletterMailId, int SmtpHostId)
        {
            MailMessage mailMessage = new MailMessage();

            SentMailLog sentMailLog = new SentMailLog();
            //List<SentMailLog> sentMailLogList= new List<SentMailLog>();
            //var newsLetterMailList = _iNewsletterMailManager.GetAllNewsletterMail().Select(x => new
            //{
            //    x.NewsletterMailId,
            //    x.Subject
            //}).ToList();

            //ViewBag.NewsletterMailId = new SelectList(newsLetterMailList, "NewsletterMailId", "Subject");
            NewsletterMail newsletterMail = _iNewsletterMailManager.GetANewsletterMail(NewsletterMailId);
            SmtpHost       smtpHost       = _iSmtpHostManager.GetASmtpHost(SmtpHostId);

            string[] ids = formCollection["NewsletterSubscriberId"].Split(new char[] { ',' });
            foreach (string id in ids)
            {
                var newsletterSubscriber = _iNewsletterSubscriberManager.GetANewsletterSubscriber(int.Parse(id));
                if (newsletterSubscriber.IsActive == true)
                {
                    mailMessage.To.Add(new MailAddress(newsletterSubscriber.NewsletterSubscriberEmail));

                    //mailMessage.From = new MailAddress(ConfigurationManager.AppSettings["UserName"]);
                    mailMessage.From       = new MailAddress(smtpHost.UserName);
                    mailMessage.Subject    = newsletterMail.Subject;
                    mailMessage.IsBodyHtml = true;
                    mailMessage.Body       = newsletterMail.Body;

                    var    allowedExtensions = new[] { ".GIF", ".PNG", ".JPG", ".JPEG" };
                    string myfile            = Path.GetFileName(newsletterMail.AttachFile);

                    var        path = ConfigurationManager.AppSettings["AttachFile"];
                    var        file = Path.Combine(Server.MapPath(path), myfile);
                    Attachment data = new Attachment(file);

                    ContentDisposition disposition = data.ContentDisposition;
                    disposition.CreationDate     = System.IO.File.GetCreationTime(file);
                    disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
                    disposition.ReadDate         = System.IO.File.GetLastAccessTime(file);

                    mailMessage.Attachments.Add(data);
                    //mailMessage.DeliveryNotificationOptions= DeliveryNotificationOptions.OnSuccess;
                    SmtpClient client = new SmtpClient();
                    //client.Host = ConfigurationManager.AppSettings["Host"];
                    client.Host = smtpHost.HostType.HostName;
                    //client.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableSsl"]);
                    client.EnableSsl = smtpHost.HostType.EnableSsl;
                    System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
                    //NetworkCred.UserName = ConfigurationManager.AppSettings["UserName"];
                    NetworkCred.UserName = smtpHost.UserName;
                    //NetworkCred.Password = ConfigurationManager.AppSettings["Password"];
                    NetworkCred.Password = smtpHost.Password;
                    //string encryptedPassword = smtpHost.Password;
                    //string password = new EncryptionDecryption().Decrypt(smtpHost.UserName, encryptedPassword);

                    client.UseDefaultCredentials = true;
                    client.Credentials           = NetworkCred;
                    //client.Port = int.Parse(ConfigurationManager.AppSettings["Port"]);
                    client.Port = int.Parse(smtpHost.HostType.PortNumber);


                    try
                    {
                        client.Send(mailMessage);
                        ViewBag.Result = "Mail Sent";
                        //if (ViewBag.Result==null)
                        //{
                        //    ViewBag.Result="Mail not sent" + newsletterSubscriber.NewsletterSubscriberEmail;
                        //}
                        sentMailLog.NewsletterSubscriberEmailId = newsletterSubscriber.NewsletterSubscriberEmail;
                        sentMailLog.NewsletterMailSubject       = newsletterMail.Subject;
                        sentMailLog.CreatedBy   = 1;
                        sentMailLog.CreatedDate = DateTime.Now;
                        sentMailLog.IsSent      = true;
                        AlphasoftWebsiteContext db = new AlphasoftWebsiteContext();
                        db.SentMailLogs.Add(sentMailLog);
                        db.SaveChanges();
                    }
                    catch (SmtpFailedRecipientException ex)
                    {
                        ViewBag.Result = ex.Message;
                    }
                }
            }
            return(RedirectToAction("Index"));
        }