/// <summary> /// saves updated email template to database /// </summary> /// <param name="EmailContent"></param> /// <param name="cid"></param> public static void UpdateTemplate(string EmailContent, int?cid) { campaign = new M_Campaigns(); using (dbcontext = new ApplicationDbContext()) { try { campaign = dbcontext.M_Campaigns.SingleOrDefault(c => c.Cid == cid); if (campaign != null) { campaign.EmailContent = WebUtility.HtmlEncode(EmailContent); dbcontext.SaveChanges(); } } catch (SqlException ex) { obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber); obj.LogException(); throw obj; } catch (Exception ex) { obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL()); obj.LogException(); throw obj; } } }
/// <summary> /// enables campaign by hanging status id /// </summary> /// <param name="cid"></param> public static void EnableCampaign(int?cid) { campaign = new M_Campaigns(); using (dbcontext = new ApplicationDbContext()) { try { campaign = dbcontext.M_Campaigns.Find(cid); campaign.IsActive = true; dbcontext.SaveChanges(); } catch (SqlException ex) { obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber); obj.LogException(); throw obj; } catch (Exception ex) { obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL()); obj.LogException(); throw obj; } } }
/// <summary> /// Serch for campaign by campaign ID /// </summary> /// <param name="cid"></param> /// <returns>Complete campaign information</returns> public static M_Campaigns FindCampaign(int?cid) { campaign = new M_Campaigns(); try { using (dbcontext = new ApplicationDbContext()) { campaign = dbcontext.M_Campaigns.Find(cid); //campaign = (from c in dbcontext.M_Campaigns // where c.Cid == cid // select new { c.Cid, c.CTypeId, c.EmailSubject, c.FromName, c.FromEmail, c.Name, c.ListId }).Single<M_Campaigns>(); return(campaign); } } catch (SqlException ex) { obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber); obj.LogException(); throw obj; } catch (Exception ex) { obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL()); obj.LogException(); throw obj; } }
public static string AddSubscribersToTracking(int cid, string userID) { subIDs = M_Campaigns.GetSubscribersForCampaign(cid); string id = Guid.NewGuid().ToString(); if (subIDs.Count != 0) { using (dbcontext = new ApplicationDbContext()) { try { foreach (var item in subIDs) { track = new M_Tracking(); track.CampId = cid; track.SubsciberId = item; track.IsOpened = false; track.IdentifierSubscriber = Guid.NewGuid().ToString(); track.IdentifierCampaign = id; track.MailStatus = false; track.UserID = userID; dbcontext.M_Trackings.Add(track); dbcontext.SaveChanges(); } } catch (SqlException ex) { obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL(), ex.LineNumber); obj.LogException(); throw obj; } catch (InvalidOperationException ex) { obj = new M_CustomException((int)ErorrTypes.InvalidOperation, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL()); obj.LogException(); throw obj; } catch (ArgumentNullException ex) { obj = new M_CustomException((int)ErorrTypes.ArgumentNullExceptions, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL()); obj.LogException(); throw obj; } catch (Exception ex) { obj = new M_CustomException((int)ErorrTypes.others, ex.InnerException.Message, ex.StackTrace, ErorrTypes.others.ToString(), Utlities.GetURL()); obj.LogException(); throw obj; } } } return(track.IdentifierCampaign); }