public bool Subscribe(int?user_id, string email, int campagin_id) { if (!StringsUtility.IsValidEmail(email)) { return(false); } Subscription old = DAManager.SubscriptionsRepository.Get(s => s.Email == email && s.CampaignId == campagin_id).FirstOrDefault(); if (old != null) { old.Active = true; } else { Subscription new_subscription = new Subscription() { Active = true, CampaignId = campagin_id, UserId = user_id == -1?null:user_id, Email = email }; new_subscription.UnsubscripeToken = RandomString(); DAManager.SubscriptionsRepository.Insert(new_subscription); } try { DAManager.Save(); } catch (Exception ex) { logService.WriteError(ex.Message, ex.Message, ex.StackTrace, ex.Source); return(false); } return(true); }
public JsonResult _IsAvailableEmail(string email) { if (StringsUtility.IsValidEmail(email)) { if (servicesManager.AccountService.IsEmailExist(email) > 0) { return(Json(new { isvalid = true, isavailable = false })); } else { return(Json(new { isvalid = true, isavailable = true })); } } else { return(Json(new { isvalid = false })); } }