public Publisher GetPublisherByCountryAndStatus(string countryCode, PublisherStatus status, Direction direction, int publisherId) { Publisher result = new Publisher(); using (MailPusherDBContext context = new MailPusherDBContext()) { var query = context.Publishers.Include(x => x.NACE); if (direction == Direction.Next) { query = query.Where(x => x.ID > publisherId); } if (direction == Direction.Previous) { query = query.Where(x => x.ID < publisherId); } if (!string.IsNullOrEmpty(countryCode)) { query = query.Where(x => x.Language == countryCode); } result = query.FirstOrDefault(x => x.Status == status); } return(result); }
public ActionResult GetPrevPublisher(string countryCode, int publisherId, PublisherStatus status) { PublisherHelper helper = new PublisherHelper(); Publisher publisher = helper.GetPublisherByCountryAndStatus(countryCode, status, Direction.Previous, publisherId); return(Json(GetPublisherEmail(publisher), JsonRequestBehavior.AllowGet)); }
public ActionResult ChangePublisherStatus(PublisherStatus status, int id) { string currentUserId = User.Identity.GetUserId(); PublisherHelper helper = new PublisherHelper(); return(Json(helper.ChangePublisherStatus(status, id, currentUserId))); }
public Email GetEmailByPublisherCountryAndStatus(string countryCode, PublisherStatus status) { Email result = new Email(); using (var context = new MailPusherDBContext()) { result = GenerateQueryForEmailByPublisherCountryAndStatus(context, countryCode, status, null, 0).FirstOrDefault(); } return(result); }
public Email GetPrevEmailByPublisherCountryAndStatus(string countryCode, PublisherStatus status, int publisherId) { Email result = new Email(); using (var context = new MailPusherDBContext()) { result = GenerateQueryForEmailByPublisherCountryAndStatus(context, countryCode, status, publisherId, Direction.Previous).FirstOrDefault(); } return(result); }
public Email GetFirstPublisherEmail(PublisherStatus status, int publisherID) { Email result = new Email(); using (var context = new MailPusherDBContext()) { result = context.Emails.OrderBy(x => x.ID).FirstOrDefault(x => x.PublisherID == publisherID); } return(result); }
public static string GetFormtedStatus(PublisherStatus status, DateTime?changed) { string datePart = string.Empty; if (changed.HasValue) { datePart = string.Format("({0:yyyy-MM-dd})", changed.Value.ToUniversalTime()); } return(string.Format("{0} {1}", status.ToString(), datePart)); }
public Publisher GetFirstPublisherByStatus(PublisherStatus status) { Publisher result = new Publisher(); using (MailPusherDBContext context = new MailPusherDBContext()) { result = context.Publishers.Include(x => x.NACE).FirstOrDefault(x => x.Status == status); } return(result); }
public int GetTotalFilteredRecords(string searchCriteria, PublisherStatus publisherStatuses, bool isPotentiallyCancelled, List <string> countries, List <int> categories, int minEmailAmount) { int result = 0; using (MailPusherDBContext context = new MailPusherDBContext()) { result = AddFilters(context, searchCriteria, publisherStatuses, isPotentiallyCancelled, countries, categories, minEmailAmount).Count(); } return(result); }
public ActionResult GetFirstPublisherEmail(string countryCode, PublisherStatus status) { //TODO move this to user settings, don't make during search!! UserSettingsHelper usHelper = new UserSettingsHelper(); usHelper.Update(User.Identity.GetUserId(), countryCode); //TODO move this to user settings, don't make during search!! EmailHelper helper = new EmailHelper(); return(Json(helper.GetEmailByPublisherCountryAndStatus(countryCode, status), JsonRequestBehavior.AllowGet)); }
public ActionResult Get(IDataTablesRequest request, PublisherStatus publisherStatuses, bool isPotentiallyCancelled, List <string> countries, List <int> categories, int minEmailAmount) { PublisherHelper helper = new PublisherHelper(); var filteredData = helper.GetPublishersWithStats(request.Start, request.Length, request.Search.Value, publisherStatuses, isPotentiallyCancelled, countries, categories, minEmailAmount); var response = DataTablesResponse.Create(request, helper.GetTotalRecords(), helper.GetTotalFilteredRecords(request.Search.Value, publisherStatuses, isPotentiallyCancelled, countries, categories, minEmailAmount), filteredData); // Easier way is to return a new 'DataTablesJsonResult', which will automatically convert your // response to a json-compatible content, so DataTables can read it when received. return(new DataTablesJsonResult(response, JsonRequestBehavior.AllowGet)); }
public Email GetFirstPublisherEmail(PublisherStatus status) { Email result = new Email(); using (var context = new MailPusherDBContext()) { var publisher = context.Publishers.FirstOrDefault(x => x.Status == status); if (publisher != null) { result = context.Emails.OrderBy(x => x.ID).FirstOrDefault(x => x.PublisherID == publisher.ID); } } return(result); }
public Publisher GetFirstPublisherByCountryAndStatus(string countryCode, PublisherStatus status) { Publisher result = new Publisher(); using (MailPusherDBContext context = new MailPusherDBContext()) { var query = context.Publishers.Include(x => x.NACE); if (!string.IsNullOrEmpty(countryCode)) { query = query.Where(x => x.Language == countryCode); } result = query.FirstOrDefault(x => x.Status == status); } return(result); }
public bool ChangePublisherStatus(PublisherStatus status, int id, string userId) { using (MailPusherDBContext context = new MailPusherDBContext()) { Publisher result = context.Publishers.FirstOrDefault(x => x.ID == id); if (status != result.Status) { result.StatusChanged = DateTime.UtcNow; } result.Status = status; result.UpdaterId = userId; result.Updated = DateTime.UtcNow; context.Entry(result).State = EntityState.Modified; context.SaveChanges(); } return(true); }
public Email GetPrevEmailByPublisherCountryAndStatus(string countryCode, PublisherStatus status, int publisherId) { EmailRepo repo = new EmailRepo(); return(Map(repo.GetPrevEmailByPublisherCountryAndStatus(countryCode, status, publisherId), countryCode)); }
public Email GetEmailByPublisherCountryAndStatus(string countryCode, PublisherStatus status) { EmailRepo repo = new EmailRepo(); return(Map(repo.GetEmailByPublisherCountryAndStatus(countryCode, status), countryCode));; }
public List <Publisher> GetPublishers(int start, int length, string searchCriteria, PublisherStatus publisherStatuses, bool isPotentiallyCancelled) { PublisherRepo repo = new PublisherRepo(); return(Map(repo.GetPuglishers(start, length, searchCriteria, publisherStatuses, isPotentiallyCancelled, null, null, 0))); }
public List <Publisher> GetPublishersWithStats(int start, int length, string searchCriteria, PublisherStatus publisherStatuses, bool isPotentiallyCancelled, List <string> countries, List <int> categories, int minEmailAmount) { PublisherRepo repo = new PublisherRepo(); List <Publisher> publishers = Map(repo.GetPuglishers(start, length, searchCriteria, publisherStatuses, isPotentiallyCancelled, countries, categories, minEmailAmount)); var publishersStats = repo.GetStats(publishers.Select(x => x.ID).ToList()); foreach (var publisher in publishers) { var currentPublisherStats = publishersStats.FirstOrDefault(x => x.PublisherId == publisher.ID); publisher.ReceivedEmails = currentPublisherStats == null ? 0 : currentPublisherStats.ReceivedEmails; } return(publishers); }
public Publisher GetFirstPublisherByStatus(PublisherStatus publisherStatus) { PublisherRepo repo = new PublisherRepo(); return(Map(repo.GetFirstPublisherByStatus(publisherStatus))); }
private IQueryable <Email> GenerateQueryForEmailByPublisherCountryAndStatus(MailPusherDBContext context, string countryCode, PublisherStatus status, int?publisherId, Direction direction) { var query = context.Publishers.Where(x => x.Status == status); if (!string.IsNullOrEmpty(countryCode)) { query = query.Where(x => x.Language == countryCode); } if (publisherId.HasValue) { if (direction == Direction.Next) { query = query.Where(x => x.ID > publisherId.Value); } if (direction == Direction.Previous) { query = query.Where(x => x.ID < publisherId.Value); } } return(query.Join(context.Emails, pub => pub.ID, em => em.PublisherID, (pub, em) => em)); }
public ActionResult GetPrevPublisherEmail(string countryCode, PublisherStatus status, int publisherId) { EmailHelper helper = new EmailHelper(); return(Json(helper.GetPrevEmailByPublisherCountryAndStatus(countryCode, status, publisherId), JsonRequestBehavior.AllowGet)); }
public List <Publisher> GetPuglishers(int start, int length, string searchCriteria, PublisherStatus publisherStatuses, bool isPotentiallyCancelled, List <string> countries, List <int> categories, int minEmailAmount) { List <Publisher> result = new List <Publisher>(); using (MailPusherDBContext context = new MailPusherDBContext()) { var query = AddFilters(context, searchCriteria, publisherStatuses, isPotentiallyCancelled, countries, categories, minEmailAmount); var tmpResult = query.Include(x => x.NACE).OrderBy(x => x.ID).Skip(start).Take(length); result = tmpResult.ToList(); } return(result); }
protected IQueryable <Publisher> AddFilters(MailPusherDBContext context, string searchCriteria, PublisherStatus publisherStatuses, bool isPotentiallyCancelled, List <string> countries, List <int> categories, int minEmailAmount) { var query = context.Publishers.Select(x => x); if (publisherStatuses != 0) { query = query.Where(x => (x.Status & publisherStatuses) > 0); } if (!string.IsNullOrEmpty(searchCriteria)) { query = query.Where(x => x.Name.Contains(searchCriteria)); } if (isPotentiallyCancelled) { var date = DateTime.UtcNow.AddDays(-30); query = query.Where(x => x.LastReceivedEmail < date); } if (countries != null && countries.Count > 0) { query = query.Where(x => countries.Contains(x.Language)); } if (categories != null && categories.Count > 0) { query = query.Where(x => categories.Contains(x.NACEID)); } if (minEmailAmount > 0) { query = query.Where(x => context.Emails.Where(y => y.PublisherID == x.ID).Count() >= minEmailAmount); } return(query); }
public int GetTotalFilteredRecords(string searchCriteria, PublisherStatus statuses, bool isPotentiallyCancelled, List <string> countries, List <int> categories, int minEmailAmount) { PublisherRepo repo = new PublisherRepo(); return(repo.GetTotalFilteredRecords(searchCriteria, statuses, isPotentiallyCancelled, countries, categories, minEmailAmount)); }
public Publisher GetPublisherByCountryAndStatus(string countryCode, PublisherStatus status, Direction direction, int publisherId) { PublisherRepo repo = new PublisherRepo(); return(Map(repo.GetPublisherByCountryAndStatus(countryCode, status, direction, publisherId), countryCode)); }
public Email GetFirstPublisherEmail(PublisherStatus status, int publisherId) { EmailRepo repo = new EmailRepo(); return(Map(repo.GetFirstPublisherEmail(status, publisherId))); }
public bool ChangePublisherStatus(PublisherStatus status, int id, string userId) { PublisherRepo repo = new PublisherRepo(); return(repo.ChangePublisherStatus(status, id, userId)); }
public Publisher GetFirstPublisherByCountryAndStatus(string countryCode, PublisherStatus publisherStatus) { PublisherRepo repo = new PublisherRepo(); return(Map(repo.GetFirstPublisherByCountryAndStatus(countryCode, publisherStatus), countryCode));; }