public static string GetCouponStatus(string coupon) { string ret = string.Empty; try { Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); objCoupon.CouponCode = coupon; List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon); if (lstCoupon.Count > 0) { if (lstCoupon[0].Status == "0") { ret = "valid"; } else { ret = "This Coupon is already Used!"; } } else { ret = "Coupon is not Valid!"; } } catch (Exception ex) { //logger.Error(ex.Message); Console.WriteLine("Error : " + ex.StackTrace); } return ret; }
protected void btnSave_Click(object sender, EventArgs e) { try { Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); objCoupon.Id = (Guid.Parse(Request.QueryString["Id"].ToString())); objCoupon.CouponCode =txtNews.Text; objCoupon.EntryCouponDate = Convert.ToDateTime(datepicker.Text); objCoupon.ExpCouponDate = Convert.ToDateTime(datepicker1.Text); objCoupon.Status = ddlStatus.SelectedValue; if (objCouponRepository.GetCouponByCouponCode(objCoupon).Count < 1 || objCouponRepository.GetCouponByCouponCode(objCoupon).Count == 0) { objCouponRepository.SetCouponById(objCoupon); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Modified Successfully');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Coupon Already Exist');", true); } } catch (Exception Err) { logger.Error(Err.Message); Response.Write(Err.Message); } }
protected void Page_Load(object sender, EventArgs e) { Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); List<Coupon> lstCoupon = objCouponRepository.GetAllCoupon(); Label2.Text = (lstCoupon.Count + 1).ToString(); if (!IsPostBack) { //if (Session["AdminProfile"] == null) //{ // Response.Redirect("Default.aspx"); //} if (Request.QueryString["Id"] != null) { try { //Coupon objCoupon = new Coupon(); //CouponRepository objCouponRepository = new CouponRepository(); //List<Coupon> lstCoupon = objCouponRepository.GetAllCoupon(); //Label2.Text = (lstCoupon.Count + 1).ToString(); //News news = objNewsRepo.getNewsDetailsbyId(Guid.Parse(Request.QueryString["Id"].ToString())); //txtNews.Text = news.NewsDetail; // datepicker.Text = news.ExpiryDate.ToString(); // ddlStatus.SelectedValue = news.Status.ToString(); } catch (Exception ex) { logger.Error(ex.Message); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //if (Session["AdminProfile"] == null) //{ // Response.Redirect("Default.aspx"); //} if (Request.QueryString["Id"] != null) { try { //NewsRepository objNewsRepo = new NewsRepository(); //News news = objNewsRepo.getNewsDetailsbyId(Guid.Parse(Request.QueryString["Id"].ToString())); CouponRepository objCouponRepository = new CouponRepository(); Coupon objCoupon=new Coupon (); objCoupon.Id = (Guid.Parse(Request.QueryString["Id"].ToString())); List<Coupon> lstcoupons = objCouponRepository.GetCouponByCouponId(objCoupon); txtNews.Text = lstcoupons[0].CouponCode; datepicker.Text = lstcoupons[0].EntryCouponDate.ToString(); datepicker1.Text = lstcoupons[0].ExpCouponDate.ToString(); ddlStatus.SelectedValue = lstcoupons[0].Status; } catch (Exception ex) { logger.Error(ex.Message); } } } }
public string Add(Coupon coupon) { string res = null; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { session.Save(coupon); transaction.Commit(); res = "Added"; } } } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
protected void btnSave_Click(object sender, EventArgs e) { try { //News objNews = new News(); //NewsRepository objNewsRepo = new NewsRepository(); Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); objCoupon.Id = Guid.NewGuid(); objCoupon.CouponCode = txtcoupons.Text; objCoupon.EntryCouponDate = DateTime.Now; objCoupon.ExpCouponDate = DateTime.Now; objCoupon.Status = "0"; if (objCouponRepository.GetCouponByCouponCode(objCoupon).Count < 1 || objCouponRepository.GetCouponByCouponCode(objCoupon).Count==0) { if (objCouponRepository.Add(objCoupon) == "Added") { Label1.Text = "Coupon Added"; txtcoupons.Text = ""; } else { Label1.Text = "Not Added"; } } else { Label1.Text = "Coupon already exist"; } } catch (Exception Err) { logger.Error(Err.Message); Response.Write(Err.Message); } }
public List<Coupon> GetCouponByCouponId(Coupon coupon) { //Coupon res = null; List<Coupon> res = new List<Coupon>(); try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { res = session.CreateQuery("from Coupon u where u.Id = : id") .SetParameter("id", coupon.Id) .List<Coupon>().ToList<Coupon>(); } } } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
/// <GetCouponByCouponId> /// Get the coupon detail by coupon Id. /// </summary> /// <param name="coupon">Set coupon value in a coupon Property Class and Pass the Object of coupon Class as a paremeter.(SocioBoard.Domain.Admin).</param> /// <returns>coupon values in the list of coupon properties classes.(List<Domain.Coupon>) </returns> public List<Coupon> GetCouponByCouponId(Coupon coupon) { //Coupon res = null; List<Coupon> res = new List<Coupon>(); try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to get coupon detail by coupon id. res = session.CreateQuery("from Coupon u where u.Id = : id") .SetParameter("id", coupon.Id) .List<Coupon>().ToList<Coupon>(); }//End transaction }//End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
/// <Add> /// Add new Coupon. /// </summary> /// <param name="user">Set Values in a coupon Class Property and Pass the Object of coupon Class (SocioBoard.Domain.Admin).</param> /// <returns>When successfully added it return Added otherwise it return null.</returns> public string Add(Coupon coupon) { string res = null; try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to add new row. session.Save(coupon); transaction.Commit(); res = "Added"; }//End transaction }//End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
protected void btnRegister_Click(object sender, ImageClickEventArgs e) { User user = new User(); UserRepository userrepo = new UserRepository(); UserActivation objUserActivation = new UserActivation(); Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); try { if (DropDownList1.SelectedValue == "Basic" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium") { if (TextBox1.Text.Trim() != "") { string resp = SBUtils.GetCouponStatus(TextBox1.Text).ToString(); if (resp != "valid") { // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert(Not valid);", true); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + resp + "');", true); return; } } if (txtPassword.Text == txtConfirmPassword.Text) { user.PaymentStatus = "unpaid"; //user.AccountType = Request.QueryString["type"]; user.AccountType = DropDownList1.SelectedValue.ToString(); if (string.IsNullOrEmpty(user.AccountType)) { user.AccountType = AccountType.Free.ToString(); } user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Id = Guid.NewGuid(); user.UserName = txtFirstName.Text + " " + txtLastName.Text; user.Password = this.MD5Hash(txtPassword.Text); user.EmailId = txtEmail.Text; user.UserStatus = 1; user.ActivationStatus = "0"; if (TextBox1.Text.Trim() != "") { user.CouponCode = TextBox1.Text.Trim().ToString(); } if (!userrepo.IsUserExist(user.EmailId)) { UserRepository.Add(user); if (TextBox1.Text.Trim() != "") { objCoupon.CouponCode = TextBox1.Text.Trim(); List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon); objCoupon.Id = lstCoupon[0].Id; objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate; objCoupon.ExpCouponDate = lstCoupon[0].ExpCouponDate; objCoupon.Status = "1"; objCouponRepository.SetCouponById(objCoupon); } Session["LoggedUser"] = user; objUserActivation.Id = Guid.NewGuid(); objUserActivation.UserId = user.Id; objUserActivation.ActivationStatus = "0"; UserActivationRepository.Add(objUserActivation); //add package start UserPackageRelation objUserPackageRelation = new UserPackageRelation(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); Package objPackage = objPackageRepository.getPackageDetails(user.AccountType); objUserPackageRelation.Id = new Guid(); objUserPackageRelation.PackageId = objPackage.Id; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.ModifiedDate = DateTime.Now; objUserPackageRelation.PackageStatus = true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); //end package SocioBoard.Helper.MailSender.SendEMail(txtFirstName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(),user.Id.ToString()); TeamRepository teamRepo = new TeamRepository(); Team team = teamRepo.getTeamByEmailId(txtEmail.Text); if (team != null) { Guid teamid = Guid.Parse(Request.QueryString["tid"]); teamRepo.updateTeamStatus(teamid); TeamMemberProfileRepository teamMemRepo = new TeamMemberProfileRepository(); List<TeamMemberProfile> lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id); foreach (TeamMemberProfile item in lstteammember) { try { SocialProfilesRepository socialRepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); socioprofile.Id = Guid.NewGuid(); socioprofile.ProfileDate = DateTime.Now; socioprofile.ProfileId = item.ProfileId; socioprofile.ProfileType = item.ProfileType; socioprofile.UserId = user.Id; socialRepo.addNewProfileForUser(socioprofile); if (item.ProfileType == "facebook") { try { FacebookAccount fbAccount = new FacebookAccount(); FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository(); FacebookAccount userAccount = fbAccountRepo.getUserDetails(item.ProfileId); fbAccount.AccessToken = userAccount.AccessToken; fbAccount.EmailId = userAccount.EmailId; fbAccount.FbUserId = item.ProfileId; fbAccount.FbUserName = userAccount.FbUserName; fbAccount.Friends = userAccount.Friends; fbAccount.Id = Guid.NewGuid(); fbAccount.IsActive = true; fbAccount.ProfileUrl = userAccount.ProfileUrl; fbAccount.Type = userAccount.Type; fbAccount.UserId = user.Id; fbAccountRepo.addFacebookUser(fbAccount); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "twitter") { try { TwitterAccount twtAccount = new TwitterAccount(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); TwitterAccount twtAcc = twtAccRepo.getUserInfo(item.ProfileId); twtAccount.FollowersCount = twtAcc.FollowersCount; twtAccount.FollowingCount = twtAcc.FollowingCount; twtAccount.Id = Guid.NewGuid(); twtAccount.IsActive = true; twtAccount.OAuthSecret = twtAcc.OAuthSecret; twtAccount.OAuthToken = twtAcc.OAuthToken; twtAccount.ProfileImageUrl = twtAcc.ProfileImageUrl; twtAccount.ProfileUrl = twtAcc.ProfileUrl; twtAccount.TwitterName = twtAcc.TwitterName; twtAccount.TwitterScreenName = twtAcc.TwitterScreenName; twtAccount.TwitterUserId = twtAcc.TwitterUserId; twtAccount.UserId = user.Id; twtAccRepo.addTwitterkUser(twtAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } else if (item.ProfileType == "instagram") { try { InstagramAccount insAccount = new InstagramAccount(); InstagramAccountRepository insAccRepo = new InstagramAccountRepository(); InstagramAccount InsAcc = insAccRepo.getInstagramAccountById(item.ProfileId); insAccount.AccessToken = InsAcc.AccessToken; insAccount.FollowedBy = InsAcc.FollowedBy; insAccount.Followers = InsAcc.Followers; insAccount.Id = Guid.NewGuid(); insAccount.InstagramId = item.ProfileId; insAccount.InsUserName = InsAcc.InsUserName; insAccount.IsActive = true; insAccount.ProfileUrl = InsAcc.ProfileUrl; insAccount.TotalImages = InsAcc.TotalImages; insAccount.UserId = user.Id; insAccRepo.addInstagramUser(insAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } else if (item.ProfileType == "linkedin") { try { LinkedInAccount linkAccount = new LinkedInAccount(); LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository(); LinkedInAccount linkAcc = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId); linkAccount.Id = Guid.NewGuid(); linkAccount.IsActive = true; linkAccount.LinkedinUserId = item.ProfileId; linkAccount.LinkedinUserName = linkAcc.LinkedinUserName; linkAccount.OAuthSecret = linkAcc.OAuthSecret; linkAccount.OAuthToken = linkAcc.OAuthToken; linkAccount.OAuthVerifier = linkAcc.OAuthVerifier; linkAccount.ProfileImageUrl = linkAcc.ProfileImageUrl; linkAccount.ProfileUrl = linkAcc.ProfileUrl; linkAccount.UserId = user.Id; linkedAccountRepo.addLinkedinUser(linkAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } } catch (Exception ex) { logger.Error(ex.Message); } } } lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>"; Response.Redirect("~/Home.aspx"); } else { lblerror.Text = "Email Already Exists " + "<a href=\"Default.aspx\">login</a>"; } } } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true); } } catch (Exception ex) { logger.Error(ex.StackTrace); lblerror.Text = "Please Insert Correct Information"; Console.WriteLine(ex.StackTrace); //Response.Redirect("Home.aspx"); } }
protected void btnRegister_Click(object sender, ImageClickEventArgs e) { Groups groups = new Groups(); GroupRepository objGroupRepository = new GroupRepository(); Team teams = new Team(); TeamRepository objTeamRepository = new TeamRepository(); try { Session["login"] = null; Registration regpage = new Registration(); User user = (User)Session["LoggedUser"]; if (DropDownList1.SelectedValue == "Free" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium") { if (TextBox1.Text.Trim() != "") { string resp = SBUtils.GetCouponStatus(TextBox1.Text).ToString(); if (resp != "valid") { // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert(Not valid);", true); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + resp + "');", true); return; } } if (user != null) { user.EmailId = txtEmail.Text; user.UserName = txtFirstName.Text + " " + txtLastName.Text; UserActivation objUserActivation = new UserActivation(); UserRepository userrepo = new UserRepository(); Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); if (userrepo.IsUserExist(user.EmailId)) { try { string acctype = string.Empty; if (Request.QueryString["type"] != null) { if (Request.QueryString["type"] == "INDIVIDUAL" || Request.QueryString["type"] == "CORPORATION" || Request.QueryString["type"] == "SMALL BUSINESS") { acctype = Request.QueryString["type"]; } else { acctype = "INDIVIDUAL"; } } else { acctype = "INDIVIDUAL"; } user.AccountType = Request.QueryString["type"]; } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } user.AccountType = DropDownList1.SelectedValue.ToString(); if (string.IsNullOrEmpty(user.AccountType)) { user.AccountType = AccountType.Free.ToString(); } if (string.IsNullOrEmpty(user.Password)) { user.Password = regpage.MD5Hash(txtPassword.Text); // userrepo.UpdatePassword(user.EmailId, user.Password, user.Id, user.UserName, user.AccountType); string couponcode = TextBox1.Text.Trim(); userrepo.SetUserByUserId(user.EmailId, user.Password, user.Id, user.UserName, user.AccountType, couponcode); try { if (TextBox1.Text.Trim() != "") { objCoupon.CouponCode = TextBox1.Text.Trim(); List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon); objCoupon.Id = lstCoupon[0].Id; objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate; objCoupon.ExpCouponDate = lstCoupon[0].ExpCouponDate; objCoupon.Status = "1"; objCouponRepository.SetCouponById(objCoupon); } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } //add userActivation try { objUserActivation.Id = Guid.NewGuid(); objUserActivation.UserId = user.Id; objUserActivation.ActivationStatus = "0"; UserActivationRepository.Add(objUserActivation); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } //add package start try { UserPackageRelation objUserPackageRelation = new UserPackageRelation(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); Package objPackage = objPackageRepository.getPackageDetails(user.AccountType); objUserPackageRelation.Id = Guid.NewGuid(); objUserPackageRelation.PackageId = objPackage.Id; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.ModifiedDate = DateTime.Now; objUserPackageRelation.PackageStatus = true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); //end package MailSender.SendEMail(txtFirstName.Text + " " + txtLastName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(), user.Id.ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } try { groups.Id = Guid.NewGuid(); groups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"]; groups.UserId = user.Id; groups.EntryDate = DateTime.Now; objGroupRepository.AddGroup(groups); teams.Id = Guid.NewGuid(); teams.GroupId = groups.Id; teams.UserId = user.Id; teams.EmailId = user.EmailId; // teams.FirstName = user.UserName; objTeamRepository.addNewTeam(teams); BusinessSettingRepository busnrepo = new BusinessSettingRepository(); //SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"]; SocioBoard.Domain.BusinessSetting objbsnssetting = new SocioBoard.Domain.BusinessSetting(); if (!busnrepo.checkBusinessExists(user.Id, groups.GroupName)) { objbsnssetting.Id = Guid.NewGuid(); objbsnssetting.BusinessName = groups.GroupName; //objbsnssetting.GroupId = team.GroupId; objbsnssetting.GroupId = groups.Id; objbsnssetting.AssigningTasks = false; objbsnssetting.AssigningTasks = false; objbsnssetting.TaskNotification = false; objbsnssetting.TaskNotification = false; objbsnssetting.FbPhotoUpload = 0; objbsnssetting.UserId = user.Id; objbsnssetting.EntryDate = DateTime.Now; busnrepo.AddBusinessSetting(objbsnssetting); } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } } } Session["LoggedUser"] = user; Response.Redirect("Home.aspx"); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } }
public int SetCouponById(Coupon coupon) { int res = 0; try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { res = session.CreateQuery("Update Coupon set CouponCode=:couponCode,EntryCouponDate=:entryCouponDate,ExpCouponDate=:expCouponDate,Status=:status where Id = :id") .SetParameter("couponCode", coupon.CouponCode) .SetParameter("entryCouponDate", coupon.EntryCouponDate) .SetParameter("expCouponDate", coupon.ExpCouponDate) .SetParameter("status", coupon.Status) .SetParameter("id", coupon.Id) .ExecuteUpdate(); transaction.Commit(); } } } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
protected void btnRegister_Click(object sender, ImageClickEventArgs e) { try { Session["login"] = null; Registration regpage = new Registration(); User user = (User)Session["LoggedUser"]; if (DropDownList1.SelectedValue == "Basic" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium") { if (TextBox1.Text.Trim() != "") { string resp = SBUtils.GetCouponStatus(TextBox1.Text).ToString(); if (resp != "valid") { // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert(Not valid);", true); ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + resp + "');", true); return; } } if (user != null) { user.EmailId = txtEmail.Text; user.UserName = txtFirstName.Text + " " + txtLastName.Text; UserActivation objUserActivation = new UserActivation(); UserRepository userrepo = new UserRepository(); Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); if (userrepo.IsUserExist(user.EmailId)) { try { string acctype = string.Empty; if (Request.QueryString["type"] != null) { if (Request.QueryString["type"] == "INDIVIDUAL" || Request.QueryString["type"] == "CORPORATION" || Request.QueryString["type"] == "SMALL BUSINESS") { acctype = Request.QueryString["type"]; } else { acctype = "INDIVIDUAL"; } } else { acctype = "INDIVIDUAL"; } user.AccountType = Request.QueryString["type"]; } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } user.AccountType = DropDownList1.SelectedValue.ToString(); if (string.IsNullOrEmpty(user.AccountType)) { user.AccountType = AccountType.Free.ToString(); } if (string.IsNullOrEmpty(user.Password)) { user.Password = regpage.MD5Hash(txtPassword.Text); // userrepo.UpdatePassword(user.EmailId, user.Password, user.Id, user.UserName, user.AccountType); string couponcode = TextBox1.Text.Trim(); userrepo.SetUserByUserId(user.EmailId, user.Password, user.Id, user.UserName, user.AccountType, couponcode); if (TextBox1.Text.Trim() != "") { objCoupon.CouponCode = TextBox1.Text.Trim(); List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon); objCoupon.Id = lstCoupon[0].Id; objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate; objCoupon.ExpCouponDate = lstCoupon[0].ExpCouponDate; objCoupon.Status = "1"; objCouponRepository.SetCouponById(objCoupon); } //add userActivation objUserActivation.Id = Guid.NewGuid(); objUserActivation.UserId = user.Id; objUserActivation.ActivationStatus = "0"; UserActivationRepository.Add(objUserActivation); //add package start UserPackageRelation objUserPackageRelation = new UserPackageRelation(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); Package objPackage = objPackageRepository.getPackageDetails(user.AccountType); objUserPackageRelation.Id = new Guid(); objUserPackageRelation.PackageId = objPackage.Id; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.ModifiedDate = DateTime.Now; objUserPackageRelation.PackageStatus = true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); //end package MailSender.SendEMail(txtFirstName.Text + " " + txtLastName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(), user.Id.ToString()); } } Session["LoggedUser"] = user; Response.Redirect("Home.aspx"); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } }
protected void btnRegister_Click(string email,string username) { try { User user = new User(); UserRepository userrepo = new UserRepository(); UserActivation objUserActivation = new UserActivation(); Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); try { user.PaymentStatus = "unpaid"; user.AccountType = AccountType.Premium.ToString(); user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddMonths(1); user.Id = Guid.NewGuid(); user.UserName = username; user.Password = this.MD5Hash("Sb1234!@#$"); user.EmailId = email; user.UserStatus = 1; user.ActivationStatus = "1"; if (!userrepo.IsUserExist(user.EmailId)) { UserRepository.Add(user); Session["LoggedUser"] = user; objUserActivation.Id = Guid.NewGuid(); objUserActivation.UserId = user.Id; objUserActivation.ActivationStatus = "1"; UserActivationRepository.Add(objUserActivation); //add package start UserPackageRelation objUserPackageRelation = new UserPackageRelation(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); Package objPackage = objPackageRepository.getPackageDetails(user.AccountType); objUserPackageRelation.Id = new Guid(); objUserPackageRelation.PackageId = objPackage.Id; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.ModifiedDate = DateTime.Now; objUserPackageRelation.PackageStatus = true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); //end package //SocioBoard.Helper.MailSender.SendEMail(txtFirstName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(), user.Id.ToString()); } else { //lblerror.Text = "Email Already Exists " + "<a href=\"Default.aspx\">login</a>"; } } catch (Exception ex) { logger.Error(ex.StackTrace); // lblerror.Text = "Please Insert Correct Information"; Console.WriteLine(ex.StackTrace); //Response.Redirect("Home.aspx"); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); //Response.Redirect("Home.aspx"); } }
/// <SetCouponById> /// Update coupon by coupon id (Guid). /// </summary> /// <param name="coupon">Set coupon value in a coupon Property Class and Pass the Object of coupon Class as a paremeter.(SocioBoard.Domain.Admin).</param> /// <returns>1 for success and 0 for fail</returns> public int SetCouponById(Coupon coupon) { int res = 0; try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to update existing data by coupon id. res = session.CreateQuery("Update Coupon set CouponCode=:couponCode,EntryCouponDate=:entryCouponDate,ExpCouponDate=:expCouponDate,Status=:status where Id = :id") .SetParameter("couponCode", coupon.CouponCode) .SetParameter("entryCouponDate", coupon.EntryCouponDate) .SetParameter("expCouponDate", coupon.ExpCouponDate) .SetParameter("status", coupon.Status) .SetParameter("id", coupon.Id) .ExecuteUpdate(); transaction.Commit(); }//End transaction }//End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return res; }
protected void btnRegister_Click(object sender, ImageClickEventArgs e) { try { User user = new User(); UserRepository userrepo = new UserRepository(); UserActivation objUserActivation = new UserActivation(); Coupon objCoupon = new Coupon(); CouponRepository objCouponRepository = new CouponRepository(); Groups groups = new Groups(); GroupRepository objGroupRepository = new GroupRepository(); Team teams = new Team(); TeamRepository objTeamRepository = new TeamRepository(); SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml"); try { if (DropDownList1.SelectedValue == "Free" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium" || DropDownList1.SelectedValue == "SocioBasic" || DropDownList1.SelectedValue == "SocioStandard" || DropDownList1.SelectedValue == "SocioPremium" || DropDownList1.SelectedValue == "SocioDeluxe") { if (TextBox1.Text.Trim() != "") { string resp = SBUtils.GetCouponStatus(TextBox1.Text).ToString(); if (resp != "valid") { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + resp + "');", true); return; } } if (txtPassword.Text == txtConfirmPassword.Text) { user.PaymentStatus = "unpaid"; user.AccountType = DropDownList1.SelectedValue.ToString(); if (string.IsNullOrEmpty(user.AccountType)) { user.AccountType = AccountType.Free.ToString(); } user.CreateDate = DateTime.Now; user.ExpiryDate = DateTime.Now.AddDays(30); user.Id = Guid.NewGuid(); user.UserName = txtFirstName.Text + " " + txtLastName.Text; user.Password = this.MD5Hash(txtPassword.Text); user.EmailId = txtEmail.Text; user.UserStatus = 1; user.ActivationStatus = "0"; if (TextBox1.Text.Trim() != "") { user.CouponCode = TextBox1.Text.Trim().ToString(); } if (!userrepo.IsUserExist(user.EmailId)) { logger.Error("Before User reg"); UserRepository.Add(user); try { groups.Id = Guid.NewGuid(); groups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"]; groups.UserId = user.Id; groups.EntryDate = DateTime.Now; objGroupRepository.AddGroup(groups); teams.Id = Guid.NewGuid(); teams.GroupId = groups.Id; teams.UserId = user.Id; teams.EmailId = user.EmailId; objTeamRepository.addNewTeam(teams); BusinessSettingRepository busnrepo = new BusinessSettingRepository(); SocioBoard.Domain.BusinessSetting objbsnssetting = new SocioBoard.Domain.BusinessSetting(); if (!busnrepo.checkBusinessExists(user.Id, groups.GroupName)) { objbsnssetting.Id = Guid.NewGuid(); objbsnssetting.BusinessName = groups.GroupName; objbsnssetting.GroupId = groups.Id; objbsnssetting.AssigningTasks = false; objbsnssetting.AssigningTasks = false; objbsnssetting.TaskNotification = false; objbsnssetting.TaskNotification = false; objbsnssetting.FbPhotoUpload = 0; objbsnssetting.UserId = user.Id; objbsnssetting.EntryDate = DateTime.Now; busnrepo.AddBusinessSetting(objbsnssetting); } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Error : " + ex.Message); logger.Error("Error : " + ex.StackTrace); } try { logger.Error("1 Request.QueryString[refid]"); if (Request.QueryString["refid"] != null) { logger.Error("3 Request.QueryString[refid]"); User UserValid = null; if (IsUserValid(Request.QueryString["refid"].ToString(), ref UserValid)) { logger.Error("Inside IsUserValid"); user.RefereeStatus = "1"; UpdateUserReference(UserValid); AddUserRefreeRelation(user, UserValid); logger.Error("IsUserValid"); } else { user.RefereeStatus = "0"; } } logger.Error("2 Request.QueryString[refid]"); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("btnRegister_Click" + ex.Message); logger.Error("btnRegister_Click" + ex.StackTrace); } if (TextBox1.Text.Trim() != "") { objCoupon.CouponCode = TextBox1.Text.Trim(); List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon); objCoupon.Id = lstCoupon[0].Id; objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate; objCoupon.ExpCouponDate = lstCoupon[0].ExpCouponDate; objCoupon.Status = "1"; objCouponRepository.SetCouponById(objCoupon); } Session["LoggedUser"] = user; objUserActivation.Id = Guid.NewGuid(); objUserActivation.UserId = user.Id; objUserActivation.ActivationStatus = "0"; UserActivationRepository.Add(objUserActivation); //add package start UserPackageRelation objUserPackageRelation = new UserPackageRelation(); UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository(); PackageRepository objPackageRepository = new PackageRepository(); try { Package objPackage = objPackageRepository.getPackageDetails(user.AccountType); objUserPackageRelation.Id = Guid.NewGuid(); objUserPackageRelation.PackageId = objPackage.Id; objUserPackageRelation.UserId = user.Id; objUserPackageRelation.ModifiedDate = DateTime.Now; objUserPackageRelation.PackageStatus = true; objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } //end package SocioBoard.Helper.MailSender.SendEMail(txtFirstName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(), user.Id.ToString()); TeamRepository teamRepo = new TeamRepository(); try { Team team = teamRepo.getTeamByEmailId(txtEmail.Text); if (team != null) { Guid teamid = Guid.Parse(Request.QueryString["tid"]); teamRepo.updateTeamStatus(teamid); TeamMemberProfileRepository teamMemRepo = new TeamMemberProfileRepository(); List<TeamMemberProfile> lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id); foreach (TeamMemberProfile item in lstteammember) { try { SocialProfilesRepository socialRepo = new SocialProfilesRepository(); SocialProfile socioprofile = new SocialProfile(); socioprofile.Id = Guid.NewGuid(); socioprofile.ProfileDate = DateTime.Now; socioprofile.ProfileId = item.ProfileId; socioprofile.ProfileType = item.ProfileType; socioprofile.UserId = user.Id; socialRepo.addNewProfileForUser(socioprofile); if (item.ProfileType == "facebook") { try { FacebookAccount fbAccount = new FacebookAccount(); FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository(); FacebookAccount userAccount = fbAccountRepo.getUserDetails(item.ProfileId); fbAccount.AccessToken = userAccount.AccessToken; fbAccount.EmailId = userAccount.EmailId; fbAccount.FbUserId = item.ProfileId; fbAccount.FbUserName = userAccount.FbUserName; fbAccount.Friends = userAccount.Friends; fbAccount.Id = Guid.NewGuid(); fbAccount.IsActive = 1; fbAccount.ProfileUrl = userAccount.ProfileUrl; fbAccount.Type = userAccount.Type; fbAccount.UserId = user.Id; fbAccountRepo.addFacebookUser(fbAccount); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } } else if (item.ProfileType == "twitter") { try { TwitterAccount twtAccount = new TwitterAccount(); TwitterAccountRepository twtAccRepo = new TwitterAccountRepository(); TwitterAccount twtAcc = twtAccRepo.getUserInfo(item.ProfileId); twtAccount.FollowersCount = twtAcc.FollowersCount; twtAccount.FollowingCount = twtAcc.FollowingCount; twtAccount.Id = Guid.NewGuid(); twtAccount.IsActive = true; twtAccount.OAuthSecret = twtAcc.OAuthSecret; twtAccount.OAuthToken = twtAcc.OAuthToken; twtAccount.ProfileImageUrl = twtAcc.ProfileImageUrl; twtAccount.ProfileUrl = twtAcc.ProfileUrl; twtAccount.TwitterName = twtAcc.TwitterName; twtAccount.TwitterScreenName = twtAcc.TwitterScreenName; twtAccount.TwitterUserId = twtAcc.TwitterUserId; twtAccount.UserId = user.Id; twtAccRepo.addTwitterkUser(twtAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } else if (item.ProfileType == "instagram") { try { InstagramAccount insAccount = new InstagramAccount(); InstagramAccountRepository insAccRepo = new InstagramAccountRepository(); InstagramAccount InsAcc = insAccRepo.getInstagramAccountById(item.ProfileId); insAccount.AccessToken = InsAcc.AccessToken; insAccount.FollowedBy = InsAcc.FollowedBy; insAccount.Followers = InsAcc.Followers; insAccount.Id = Guid.NewGuid(); insAccount.InstagramId = item.ProfileId; insAccount.InsUserName = InsAcc.InsUserName; insAccount.IsActive = true; insAccount.ProfileUrl = InsAcc.ProfileUrl; insAccount.TotalImages = InsAcc.TotalImages; insAccount.UserId = user.Id; insAccRepo.addInstagramUser(insAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } else if (item.ProfileType == "linkedin") { try { LinkedInAccount linkAccount = new LinkedInAccount(); LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository(); LinkedInAccount linkAcc = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId); linkAccount.Id = Guid.NewGuid(); linkAccount.IsActive = true; linkAccount.LinkedinUserId = item.ProfileId; linkAccount.LinkedinUserName = linkAcc.LinkedinUserName; linkAccount.OAuthSecret = linkAcc.OAuthSecret; linkAccount.OAuthToken = linkAcc.OAuthToken; linkAccount.OAuthVerifier = linkAcc.OAuthVerifier; linkAccount.ProfileImageUrl = linkAcc.ProfileImageUrl; linkAccount.ProfileUrl = linkAcc.ProfileUrl; linkAccount.UserId = user.Id; linkedAccountRepo.addLinkedinUser(linkAccount); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); logger.Error(ex.Message); } } } catch (Exception ex) { logger.Error(ex.Message); } } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } #region SetInvitationStatusAfterSuccessfulRegistration try { if (Request.QueryString["refid"] != null) { string refid = Request.QueryString["refid"]; int res = SetInvitationStatusAfterSuccessfulRegistration(refid, txtEmail.Text); } } catch (Exception ex) { logger.Error(ex.Message); } #endregion try { lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>"; Response.Redirect("~/Home.aspx"); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } else { lblerror.Text = "Email Already Exists " + "<a id=\"loginlink\" href=\"#\">login</a>"; } } } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true); } } catch (Exception ex) { logger.Error(ex.StackTrace); lblerror.Text = "Success!"; Console.WriteLine(ex.StackTrace); //Response.Redirect("Home.aspx"); } } catch (Exception ex) { logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); //Response.Redirect("Home.aspx"); } }