//SubscribeRegisterUser public bool SubscribeRegisterUser(User u) { try { if (u == null) { throw new Exception("The user doesn't exist"); } OuterSubscription os = dataContext.OuterSubscriptions.SingleOrDefault(OU => OU.Email == u.Email); if (os != null) { os.IsActive = true; os.IsRecievingUpdates = u.RecieveNewsUpdates.GetValueOrDefault(false); os.IsRecievingWeeklySpecials = u.RecieveWeeklySpecials.GetValueOrDefault(false); SubmitChanges(); return(false); } os = new OuterSubscription(); os.Email = u.Email; os.EmailConfirm = u.Email; os.IsActive = true; os.IsRecievingUpdates = u.RecieveNewsUpdates.GetValueOrDefault(false); os.IsRecievingWeeklySpecials = u.RecieveWeeklySpecials.GetValueOrDefault(false); os.FirstName = u.AddressCard_Billing.FirstName; os.LastName = u.AddressCard_Billing.LastName; dataContext.OuterSubscriptions.InsertOnSubmit(os); SubmitChanges(); } catch (Exception ex) { Logger.LogException("[user_id=" + u != null ? u.ID.ToString() : "null" + "]", ex); return(false); } return(true); }
//ActivateOuterSubscription public bool ActivateOuterSubscription(long?id) { bool res = true; try { if (!id.HasValue) { throw new Exception("The code is not correct."); } OuterSubscription os = dataContext.OuterSubscriptions.SingleOrDefault(OS => OS.ID == id.Value); if (os == null) { throw new Exception("Outer subscription doesn't exist."); } os.IsActive = true; SubmitChanges(); } catch (Exception ex) { Logger.LogException("[ID=" + id + "]", ex); res = false; } return(res); }
//ActivateOuterSubscription public bool ActivateOuterSubscription(long outersubscription_id) { try { OuterSubscription os = dataContext.OuterSubscriptions.SingleOrDefault(OS => OS.ID == outersubscription_id); if (os == null) { return(false); } User user = GetUserByEmail(os.Email, false); if (user != null) { user.RecieveNewsUpdates = os.IsRecievingUpdates; user.RecieveWeeklySpecials = os.IsRecievingWeeklySpecials; } os.IsActive = true; SubmitChanges(); if (user != null) { UpdateUserObjectCache(user); } } catch (Exception ex) { Logger.LogException(ex); return(false); } return(true); }
//AddOuterSubscription public void AddOuterSubscription(OuterSubscription os) { try { os.IsActive = false; dataContext.OuterSubscriptions.InsertOnSubmit(os); SubmitChanges(); } catch (Exception ex) { Logger.LogException(ex); } }
//UnsubscribeFromOuterSubscribtionByID public bool UnsubscribeFromOuterSubscribtionByID(long id) { try { OuterSubscription os = dataContext.OuterSubscriptions.Where(OS => OS.ID == id).SingleOrDefault(); if (os == null) { return(false); // throw new Exception("Outer subscription doesn't exist."); } dataContext.OuterSubscriptions.DeleteOnSubmit(os); dataContext.SubmitChanges(); } catch { return(false); } return(true); }
//UnsubscribeFromEmail public bool UnsubscribeFromEmail(string email) { try { email = email.Trim(); OuterSubscription sub = dataContext.OuterSubscriptions.Where(S => S.Email == email).SingleOrDefault(); if (sub == null) { return(false); } dataContext.OuterSubscriptions.DeleteOnSubmit(sub); SubmitChanges(); } catch { return(false); } return(true); }
//UnsubscribeFromOuterSubscribtionByID public bool UnsubscribeFromOuterSubscribtionByID(long id) { try { OuterSubscription os = dataContext.OuterSubscriptions.Where(OS => OS.ID == id).SingleOrDefault(); if (os == null) { return(false); // throw new Exception("Outer subscription doesn't exist."); } dataContext.OuterSubscriptions.DeleteOnSubmit(os); SubmitChanges(); } catch //(Exception ex) { //Logger.LogException("[id=" + id.ToString() + "]", ex); return(false); } return(true); }
//UnsubscribeFromEmail public bool UnsubscribeFromEmail(string email) { try { OuterSubscription sub = dataContext.OuterSubscriptions.Where(S => S.Email == email).SingleOrDefault(); if (sub == null) { return(false); //throw new Exception("The email doesn't exist"); } dataContext.OuterSubscriptions.DeleteOnSubmit(sub); SubmitChanges(); } catch // (Exception ex) { //Logger.LogException("[Email=" + email + "]", ex); return(false); } return(true); }
//SubscribeRegisterUser public bool SubscribeRegisterUser(User u) { try { if (u == null) { throw new Exception("The user doesn't exist"); } OuterSubscription os = dataContext.OuterSubscriptions.SingleOrDefault(OU => OU.Email == u.Email); if (os != null) { os.IsActive = true; os.IsRecievingUpdates = !u.NotRecieveNewsUpdates; os.IsRecievingWeeklySpecials = !u.NotRecieveWeeklySpecials; SubmitChanges(); return(false); } AddressCard acB = GetAddressCard(u.Billing_AddressCard_ID.GetValueOrDefault(-1), true); os = new OuterSubscription(); os.Country = acB.Country.Title; os.Email = u.Email; os.EmailConfirm = u.Email; os.IsActive = true; os.IPAddress = Consts.UsersIPAddress; os.IsRecievingUpdates = !u.NotRecieveNewsUpdates; os.IsRecievingWeeklySpecials = !u.NotRecieveWeeklySpecials; os.FirstName = acB.FirstName; os.LastName = acB.LastName; os.State = acB.State; dataContext.OuterSubscriptions.InsertOnSubmit(os); SubmitChanges(); } catch (Exception ex) { Logger.LogException("[user_id=" + u != null?u.ID.ToString():"null" + "]", ex); return(false); } return(true); }
//SubscribeRegisterUser public bool SubscribeRegisterUser(User u) { try { if (u == null) throw new Exception("The user doesn't exist"); OuterSubscription os = dataContext.OuterSubscriptions.SingleOrDefault(OU => OU.Email == u.Email); if (os != null) { os.IsActive = true; os.IsRecievingUpdates = u.RecieveNewsUpdates.GetValueOrDefault(false); os.IsRecievingWeeklySpecials = u.RecieveWeeklySpecials.GetValueOrDefault(false); SubmitChanges(); return false; } os = new OuterSubscription(); os.Email = u.Email; os.EmailConfirm = u.Email; os.IsActive = true; os.IsRecievingUpdates = u.RecieveNewsUpdates.GetValueOrDefault(false); os.IsRecievingWeeklySpecials = u.RecieveWeeklySpecials.GetValueOrDefault(false); os.FirstName = u.AddressCard_Billing.FirstName; os.LastName = u.AddressCard_Billing.LastName; dataContext.OuterSubscriptions.InsertOnSubmit(os); SubmitChanges(); } catch (Exception ex) { Logger.LogException("[user_id=" + u != null ? u.ID.ToString() : "null" + "]", ex); return false; } return true; }
public ActionResult FreeEmailAlertsRegistrationSuccess() { OuterSubscription os = new OuterSubscription(); if (!TryUpdateModel(os, new[] { "Country", "Email", "EmailConfirm", "FirstName", "LastName", "State", "IsRecievingWeeklySpecials", "IsRecievingUpdates" })) return View("FreeEmailAlertsRegister", os); os.Validate(ModelState); if (ModelState.IsValid) { UserRepository.AddOuterSubscription(os); Mail.SendFreeEmailRegisterConfirmation(os.Email, os.FirstName, os.LastName, AppHelper.GetSiteUrl(Url.Action("FreeEmailAlertsRegisterConfirm", "Home", new { id = os.ID }))); return View(); } return View("FreeEmailAlertsRegister", os); }