コード例 #1
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Text,Description,DateBegin,DateEnd,Available,CompanyId")] Push push)
        {
            if (ModelState.IsValid)
            {
                db.PushSet.Add(push);
                await db.SaveChangesAsync();

                var users = from u in db.UserSet
                            join f in db.FollowingsSet
                            on u.Id equals f.UserId
                            where (f.CompanyId == push.CompanyId)
                            select u;
                foreach (var item in users)
                {
                    var p = new Pushes();
                    p.Checked = false;
                    p.Push    = push;
                    p.User    = item;
                    db.PushesSet.Add(p);
                }
                await db.SaveChangesAsync();

                //TODO send gcm push SendGCMPush(push);
                return(RedirectToAction("Index"));
            }

            ViewBag.CompanyId = new SelectList(db.CompanySet, "Id", "Name", push.CompanyId);
            return(View(push));
        }
コード例 #2
0
        public Updates <T> Push <TProperty>(Expression <Func <T, List <TProperty> > > propertyExpression, TProperty value)
        {
            var update = UpdateCollection <T> .Property(propertyExpression, value);

            Pushes = Pushes ?? new List <UpdateCollection <T> >();
            Pushes.Add(update);
            return(this);
        }