internal static string ReturnPromotionType(string companyid, string promotionid) { var company = new CompanyManager().FindCompanyById(companyid); foreach (var item in company.Promotions) { if (promotionid.Equals(item.Id)) { return("Promotion"); } } foreach (var item in company.Events) { if (promotionid.Equals(item.Id)) { return("Event"); } } foreach (var item in company.DiscountCoupons) { if (promotionid.Equals(item.Id)) { return("Discount Coupon"); } } return(null); }
public static async Task CreateNotificationAsync(String userid, String companyid, String promotionid, int notificationType) { var temp = new Notification { UserId = userid, Logo = new CompanyManager().FindCompanyById(companyid).Logo, CompanyName = new CompanyManager().FindCompanyById(companyid).Name, CompanyId = companyid, PromotionId = promotionid, PromotionType = CompanyManager.ReturnPromotionType(companyid, promotionid), Message = GenerateMessage(notificationType), NotificationType = notificationType }; if (UseBackend.Backend) { var notificationJson = JsonConvert.SerializeObject(temp); HttpClient client = new HttpClient(); var res = await client.PostAsync(GETString, new StringContent(notificationJson, System.Text.Encoding.UTF8, "application/json")).ConfigureAwait(false); } else { notifications.Add(temp); } }
public List <Company> Search(String nameFilter, String typeFilter, bool hasPromotionsFilter) { var result = new CompanyManager().GetCompanies(); if (!string.IsNullOrEmpty(nameFilter)) { result = result.Where(c => c.Name.Contains(nameFilter)).ToList(); } if (!string.IsNullOrEmpty(typeFilter) && !typeFilter.Equals("Don't filter on type")) { result = result.Where(c => c.Type == typeFilter).ToList(); } if (hasPromotionsFilter) { result = result.Where(c => c.Promotions.Count > 0 || c.Events.Count > 0 || c.DiscountCoupons.Count > 0).ToList(); } return(result); }