// tạo lô bài viết tin tức public int CreateNewsDekko(string Content, string Title, string Description, int Type, int?TypeSend, string UrlImage, int Status, int Display, int CreateUserID) { try { News news = new News(); NotifyBusiness notify = new NotifyBusiness(); PackageBusiness package = new PackageBusiness(); news.CreateUserID = CreateUserID; news.CategoryID = 1; news.Title = Title; news.Description = Description; news.Content = Content; news.Type = Type; news.DisplayOrder = Display; if (TypeSend == null) { news.TypeSend = 8; } else { news.TypeSend = TypeSend.Value; } news.Status = Status; news.UrlImage = UrlImage; news.CreateDate = DateTime.Today; news.IsActive = SystemParam.ACTIVE; cnn.News.Add(news); cnn.SaveChanges(); if (TypeSend != null && Status == 1) { int newsID = cnn.News.Where(u => u.IsActive.Equals(SystemParam.ACTIVE)).OrderByDescending(u => u.ID).FirstOrDefault().ID; List <int> deviceID = cnn.Customers.Where(c => c.IsActive.Equals(1) && !String.IsNullOrEmpty(c.DeviceID) && c.DeviceID.Length > 15 && c.Role.Equals(SystemParam.ROLL_CUSTOMER)).Select(c => c.ID).ToList(); foreach (var cus in deviceID) { notify.CreateNoti(cus, 6, 0, Title, Title, newsID); } } return(SystemParam.SUCCESS); } catch (Exception e) { e.ToString(); return(SystemParam.ERROR); } }
public int AddPoint(string ListChecked, int Point, string Description) { string[] listBox = ListChecked.Split(','); List <int> boxes = new List <int>(); foreach (var number in listBox) { if (number != null && number != "") { boxes.Add(Convert.ToInt32(number)); } } try { foreach (var box in boxes) { NotifyBusiness notify = new NotifyBusiness(); PackageBusiness package = new PackageBusiness(); PointBusiness pointBusiness = new PointBusiness(); Customer customer = cnn.Customers.Find(box); customer.Point += Point; cnn.SaveChanges(); string code = Util.CreateMD5(DateTime.Now.ToString()).Substring(0, 6); pointBusiness.CreateHistoryes(box, Point, SystemParam.HISPOINT_HE_THONG_CONG_DIEM, code, Description, null); string contennotify = "Bạn vừa được cộng " + Point + " điểm từ hệ thống"; notify.CreateNoti(box, SystemParam.HISPOINT_HE_THONG_CONG_DIEM, 0, contennotify, contennotify, null); //if(customer.DeviceID.Length > 0) //{ // NotifyDataModel notifyData = new NotifyDataModel(); // notifyData.id = customer.ID; // notifyData.type = SystemParam.HISPOINT_HE_THONG_CONG_DIEM; // package.StartPushNoti(notifyData, customer.DeviceID, contennotify, SystemParam.ROLE_ADMIN); // string a = notify.PushNotify(customer.ID, contennotify, SystemParam.HISPOINT_HE_THONG_CONG_DIEM); //} } return(1); } catch (Exception ex) { ex.ToString(); return(0); } }