protected override void MergeSubItems(Order model) { ItemRepository.MergeList(model.bvin, model.StoreId, model.Items); NotesRepository.MergeList(model.bvin, model.StoreId, model.Notes); CouponRepository.MergeList(model.bvin, model.StoreId, model.Coupons); PackageRepository.MergeList(model.bvin, model.StoreId, model.Packages); ReturnsRepository.MergeList(model.bvin, model.StoreId, model.Returns); }
public bool SaveAuthorCoupon(ref AuthorCouponDTO dto, out string error) { if (dto.TotalInstances > 1) { return(SaveAuthorCoupon(ref dto, dto.TotalInstances, out error)); } if (!IsCouponValid(ref dto, out error)) { return(false); } if (!IsCouponCodeValid(dto.CouponCode, dto.CouponId, out error)) { error = String.IsNullOrEmpty(error) ? "Coupon code already exists" : error; return(false); } try { if (dto.CouponId < 0) //new course { var entity = dto.AuthorCouponDto2CouponEntity(); CouponRepository.Add(entity); if (!CouponRepository.UnitOfWork.CommitAndRefreshChanges(out error)) { return(false); } dto.CouponId = entity.Id; } else { var entity = CouponRepository.GetById(dto.CouponId); if (entity == null) { error = "Course entity not found"; return(false); } entity.UpdateCouponEntity(dto); if (!CouponRepository.UnitOfWork.CommitAndRefreshChanges(out error)) { return(false); } } return(SaveCouponInstance(dto, out error)); } catch (Exception ex) { error = Utils.FormatError(ex); Logger.Error("save author coupon dto", dto.BundleId ?? -1, ex, CommonEnums.LoggerObjectTypes.Coupon); return(false); } }
public void FindById_notFound_returnNotFoundResult() { var repository = new CouponRepository(_databaseSettings); var target = new CouponController(new CouponManager(repository, _mapper)); var actual = target.FindById(Invalid_ID); Assert.IsType <NotFoundResult>(actual.Result); }
public void Setup() { _connection = new SqliteConnection("Datasource=:memory:"); _connection.Open(); _options = new DbContextOptionsBuilder <BarOMeterContext>().UseSqlite(_connection).Options; _context = new BarOMeterContext(_options); _uut = new CouponRepository(_context); _context.Database.EnsureCreated(); }
public CouponControllerTest() { MongoSetup.Start(); _mongoUtility = new MongoUtility(); var shoppingCartDatabaseSettings = _mongoUtility.RetrieveDatabaseSettings(); _mongoUtility.CreateDatabase("ShoppingCartDatabaseSettings"); _couponRepository = new CouponRepository(shoppingCartDatabaseSettings); }
public HttpResponseMessage CreateOrUpdate(CouponRequest couponRequest) { string apiName = "CreateOrUpdate(CouponRequest couponRequest=\n{" + couponRequest + "})"; var guid = Guid.NewGuid(); logger.Info("Guid: \"{0}\" api/{1}/{2} was invoked", guid, controllerName, apiName); ICouponRepository couponRepository = new CouponRepository(); try { var couponToUpdate = couponRepository.GetByNameAndCompanyId(couponRequest.Name, couponRequest.CompanyId); if (couponToUpdate == null) {//Create logger.Info("Guid: \"{0}\" Start Creating new Coupon", guid); var newCoupon = new Coupons.DAL.Coupons { Name = couponRequest.Name, CompanyId = couponRequest.CompanyId, Start_Date = couponRequest.Start_date, End_Date = couponRequest.End_date, Amount = couponRequest.Amount, Type = couponRequest.Type, Message = couponRequest.Message, Price = couponRequest.Price, Image = couponRequest.Image }; couponRepository.Create(newCoupon); return(CreateResponseMessage(newCoupon)); } else {//Update logger.Info("Guid: \"{0}\" Start Updating Coupon", guid); couponToUpdate.Name = couponRequest.Name; couponToUpdate.CompanyId = couponRequest.CompanyId; couponToUpdate.Start_Date = couponRequest.Start_date; couponToUpdate.End_Date = couponRequest.End_date; couponToUpdate.Amount = couponRequest.Amount; couponToUpdate.Type = couponRequest.Type; couponToUpdate.Message = couponRequest.Message; couponToUpdate.Price = couponRequest.Price; couponToUpdate.Image = couponRequest.Image; couponRepository.SaveChanges(); return(CreateResponseMessage(couponToUpdate)); } } catch (Exception ex) { logger.Error("Guid: \"{0}\" General Error: {1}", guid, ex); return(CreateGeneralResultMessage(ex.ToString(), false, ApiStatusCodes.InternalServerError)); } }
public void Creates_A_Coupon() { CouponRepository couponRepository = new CouponRepository(_shoppingCartDatabaseSettings); var coupon = new Coupon() { Amount = 10, Type = CouponType.Percentage, ExpiryDate = DateTime.Now }; var result = couponRepository.Create(coupon); result.Should().BeEquivalentTo(coupon); }
public void GetAwardedCouponList() { // Arrange var obj = new CouponRepository(); // Act var ret = obj.GetAwardedCouponList(); // Assert Assert.True(ret.Count > 0); }
public UnitOfWork(ApplicationDbContext db) { _db = db; Category = new CategoryRepository(_db); SubCategory = new SubCategoryRepository(_db); ShoppingCart = new ShoppingCartRepository(_db); AutoPart = new AutoPartRepository(_db); ApplicationUser = new ApplicationUserRepository(_db); Coupon = new CouponRepository(_db); OrderDetails = new OrderDetailsRepository(_db); OrderHeader = new OrderHeaderRepository(_db); }
public void DeleteById_CouponFound_RemoveFromDb() { var target = new CouponRepository(_databaseSettings); var coupon = new Coupon(); target.Create(coupon); target.DeleteById(coupon.Id); var result = target.FindById(coupon.Id); Assert.Null(result); }
public void GenerateAwardedCoupon() { // Arrange var obj = new CouponRepository(); Random objRnd = new Random(); var rnd = objRnd.Next(50000, 1000000).ToString(); // Act obj.InsertAwardedCoupon(rnd); // Assert Assert.True(obj.CheckExistingAwardedCoupon(rnd)); }
public void Finds_Coupon_By_Id() { CouponRepository couponRepository = new CouponRepository(_shoppingCartDatabaseSettings); var date = DateTime.Now.AddDays(-10); var coupon = new Coupon() { Amount = 10, Type = CouponType.Percentage, ExpiryDate = date }; var createdCoupon = couponRepository.Create(coupon); string couponId = createdCoupon.Id; var result = couponRepository.FindById(couponId); result.Id.Should().Be(createdCoupon.Id); }
private void CreateRepos() { mEntities = new V308CMSEntities(); ProductRepos = new ProductRepository(mEntities); ProductRepos.PageSize = PageSize; ProductHelper.ProductShowLimit = ProductRepos.PageSize; AccountRepos = new AccountRepository(mEntities); NewsRepos = new NewsRepository(mEntities); CommentRepo = new TestimonialRepository(mEntities); CategoryRepo = new CategoryRepository(mEntities); LinkRepo = new LinkRepository(mEntities); BannerRepo = new BannerRepository(mEntities); TicketRepo = new TicketRepository(mEntities); CouponRepo = new CouponRepository(mEntities); CouponRepo.PageSize = PageSize; }
public void Deletes_A_Coupon() { CouponRepository couponRepository = new CouponRepository(_shoppingCartDatabaseSettings); var coupon = new Coupon() { Amount = 10, Type = CouponType.Percentage, ExpiryDate = DateTime.Now }; var createdCoupon = couponRepository.Create(coupon); string couponId = createdCoupon.Id; couponRepository.Remove(couponId); var result = couponRepository.FindById(couponId); result.Should().BeNull(); }
public void GetById_CouponNotFound_ReturnNull() { var target = new CouponRepository(_databaseSettings); var coupon1 = new Coupon(); var coupon2 = new Coupon(); var coupon3 = new Coupon(); target.Create(coupon1); target.Create(coupon2); target.Create(coupon3); var actual = target.FindById(Invalid_ID); Assert.Null(actual); }
protected override void GetSubItems(List <Order> models) { var orderIds = models.Select(o => o.bvin).ToList(); var allItems = ItemRepository.FindForOrders(orderIds); var allNotes = NotesRepository.FindForOrders(orderIds); var allCoupons = CouponRepository.FindForOrders(orderIds); var allPackages = PackageRepository.FindForOrders(orderIds); var allReturns = ReturnsRepository.FindForOrders(orderIds); foreach (var model in models) { model.Items = allItems.Where(i => i.OrderBvin == model.bvin).ToList(); model.Notes = allNotes.Where(i => i.OrderID == model.bvin).ToList(); model.Coupons = allCoupons.Where(i => i.OrderBvin == model.bvin).ToList(); model.Packages = allPackages.Where(i => i.OrderId == model.bvin).ToList(); model.Returns = allReturns.Where(i => i.OrderBvin == model.bvin).ToList(); } }
private bool IsBundleCouponNameValid(int couponId, int bundleId, string couponName, out string error) { error = string.Empty; try { if (couponId < 0) { return(!CouponRepository.IsAny(x => x.BundleId == bundleId && x.CouponName == couponName)); } return(!CouponRepository.IsAny(x => x.BundleId == bundleId && x.CouponName == couponName && x.Id != couponId)); } catch (Exception ex) { error = Utils.FormatError(ex); return(false); } }
public HttpResponseMessage Get(int id) { string apiName = "Get(int couponId{" + id + "})"; var guid = Guid.NewGuid(); logger.Info("Guid: \"{0}\" api/{1}/{2} was invoked", guid, controllerName, apiName); ICouponRepository couponRepository = new CouponRepository(); try { var response = couponRepository.Get(id); return(CreateResponseMessage(response)); } catch (Exception ex) { logger.Error("Guid: \"{0}\" General Error: {1}", guid, ex); return(CreateGeneralResultMessage(ex.ToString(), false, ApiStatusCodes.InternalServerError)); } }
public ICalculator Create() { try { Coupon coupon = CouponRepository.Get(CouponId); if (coupon.Discount.DiscountType == DiscountType.ShippingBased) { return(new ShippingBasedDiscountCalculator(ShippingCost)); } return((ICalculator)Activator.CreateInstance( Type.GetType($"ShoppingCart.Core.Calculators.Discount.{coupon.Discount.DiscountType}DiscountCalculator"), new object[] { coupon, ProductRepository, CouponRepository, CartItems })); } catch (Exception e) { Console.Out.WriteLine(e); return(UnknownDiscountCalculator.Instance); } }
public void Delete_ReturnNoConentAndDeleteItem() { var repository = new CouponRepository(_databaseSettings); var coupon = new Coupon { CouponType = CouponType.Percentage, Value = 10 }; repository.Create(coupon); var target = new CouponController(new CouponManager(repository, _mapper)); var actual = target.DeleteCoupon(coupon.Id); Assert.IsType <NoContentResult>(actual); var couponFindResult = target.FindById(Invalid_ID); Assert.IsType <NotFoundResult>(couponFindResult.Result); }
public void FindById_HasOneCartWithSameId_returnAllShoppingCartsInformation() { var repository = new CouponRepository(_databaseSettings); var coupon = new Coupon { CouponType = CouponType.Percentage, Value = 10 }; repository.Create(coupon); var target = new CouponController(new CouponManager(repository, _mapper)); var actual = target.FindById(coupon.Id); var expected = new CouponDto(coupon.Id, CouponType.Percentage, 10, coupon.Expiration); Assert.Equal(expected, actual.Value); }
public CouponBaseDTO GetCouponBaseToken(int couponInstanceId, out string error) { error = string.Empty; var inst = CouponInstanceRepository.GetById(couponInstanceId); if (inst == null) { error = "coupon instance not found"; return(null); } var coupon = CouponRepository.GetById(inst.CouponId); if (coupon == null) { error = "coupon not found"; return(null); } return(coupon.Entity2CouponBaseDTO()); }
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); } }
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 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"); } }
public CouponValidationToken ValidateCoupon(int priceLineId, int couponOwnerId, int?courseId, int?bundleId, int couponInstanceId) { var result = new CouponValidationToken { IsValid = false , Discount = 0 }; var inst = CouponInstanceRepository.GetById(couponInstanceId); if (inst == null) { result.Message = "coupon instance not found"; return(result); } var coupon = CouponRepository.GetById(inst.CouponId).Entity2AuthorCouponDTO(); if (coupon == null) { result.Message = "coupon not found"; return(result); } var priceToken = GetItemPriceToken(priceLineId); if (priceToken == null) { result.Message = "Price Line not found"; return(result); } decimal basePrice; if (courseId != null) { var course = CourseRepository.GetById((int)courseId); if (course == null) { result.Message = "course not found"; return(result); } if (coupon.CourseId != null) { if (coupon.CourseId != courseId) { result.Message = "coupon not allowed to this course"; return(result); } } else { if (coupon.OwnerUserId == null || (coupon.OwnerUserId != course.AuthorUserId)) { result.Message = "coupon not allowed to this course"; return(result); } } var itemPrice = priceToken.Price; if (itemPrice == 0) { result.Message = "invalid price"; return(result); } basePrice = itemPrice; } else if (bundleId != null) { var bundle = BundleRepository.GetById((int)bundleId); if (bundle == null) { result.Message = "bundle not found"; return(result); } if (coupon.BundleId != null) { if (coupon.BundleId != bundleId) { result.Message = "coupon not allowed to this bundle"; return(result); } } else { if (coupon.OwnerUserId == null || (coupon.OwnerUserId != bundle.AuthorId)) { result.Message = "coupon not allowed to this bundle"; return(result); } } var itemPrice = priceToken.Price; if (itemPrice == 0) { result.Message = "invalid price"; return(result); } basePrice = itemPrice; } else { result.Message = "course or bundle required"; return(result); } var objectName = courseId != null ? "course" : "bundle"; result.OriginalPrice = basePrice; result.FinalPrice = basePrice; if ((coupon.CourseId.HasValue && coupon.CourseId != courseId)) { result.Message = "This coupon is not allowed for this " + objectName; } else if (coupon.ExpirationDate < DateTime.Now.AddDays(-1)) { result.Message = "This coupon is expired"; } else if (inst.UsageLimit != -1 && inst.SALE_OrderLines.Count >= inst.UsageLimit) { result.Message = "This coupon is no longer valid"; } else { if (priceToken.PriceType == BillingEnums.ePricingTypes.SUBSCRIPTION && coupon.Type != CourseEnums.CouponType.SUBSCRIPTION) { result.Message = "This coupon is not allowed for this " + objectName; return(result); } result.IsValid = true; switch (coupon.Type) { case CourseEnums.CouponType.PERCENT: case CourseEnums.CouponType.SUBSCRIPTION: result.Discount = (decimal)(coupon.Amount != null ? basePrice * (coupon.Amount / 100) : 0); result.FinalPrice = CalculateDiscountedPrice(basePrice, coupon.Amount ?? 0, CourseEnums.CouponType.PERCENT); result.IsFree = result.FinalPrice == 0; result.Message = priceToken.PriceType == BillingEnums.ePricingTypes.SUBSCRIPTION ? String.Format("The price of this {2} is now {1:0.00} for the initial {0} months of your subscription. After that, regular rates shall apply", coupon.SubscriptionMonths ?? 0, result.FinalPrice, objectName) : String.Format("Coupon code is valid for a discount of {0}%. Your price is: {1} {2:0.00}", coupon.Amount, priceToken.Currency.ISO, result.FinalPrice); break; case CourseEnums.CouponType.FIXED: if (priceToken.PriceType == BillingEnums.ePricingTypes.SUBSCRIPTION) { result.IsValid = false; result.Message = "Fixed amount coupon can't be applied to subscription"; } else { result.Discount = coupon.Amount ?? 0; result.FinalPrice = CalculateDiscountedPrice(basePrice, coupon.Amount ?? 0, CourseEnums.CouponType.FIXED); result.IsFree = result.FinalPrice == 0; result.Message = string.Format("Coupon code is valid for a discount of {1} {0:0.00}, Your price is: {1} {2:0.00}", result.Discount, priceToken.Currency.ISO, result.FinalPrice); } break; case CourseEnums.CouponType.FREE: result.Discount = basePrice; result.FinalPrice = 0; result.IsFree = true; result.Message = "This coupon entitles you to get this course for free. Click the button below to complete the process."; break; } } return(result); }
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"); } }
public CouponService(CouponRepository couponRepository) => _couponRepository = couponRepository;
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" || 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(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 CouponService() { _couponRepository = new CouponRepository(); }