Exemplo n.º 1
0
        public IActionResult GetByNhoodAndType(uint nhoodId, DbBulletinType bulletinType)
        {
            var api = Api.INSTANCE;

            using (var da = api.DAFactory.Get())
            {
                var bulletins = da.BulletinPosts.GetByNhoodId(nhoodId, 0).Where(x => x.type == bulletinType);
                if (bulletins == null)
                {
                    return(ApiResponse.Json(HttpStatusCode.NotFound, new JSONBulletinError("Bulletins not found")));
                }

                List <JSONBulletin> bulletinJson = new List <JSONBulletin>();
                foreach (var bulletin in bulletins)
                {
                    bulletinJson.Add(new JSONBulletin
                    {
                        bulletin_id     = bulletin.bulletin_id,
                        neighborhood_id = bulletin.neighborhood_id,
                        avatar_id       = bulletin.avatar_id,
                        title           = bulletin.title,
                        body            = bulletin.body,
                        date            = bulletin.date,
                        flags           = bulletin.flags,
                        lot_id          = bulletin.lot_id,
                        type            = bulletin.type
                    });
                }
                var bulletinsJson = new JSONBulletins();
                bulletinsJson.bulletins = bulletinJson;
                return(ApiResponse.Json(HttpStatusCode.OK, bulletinsJson));
            }
        }
Exemplo n.º 2
0
 public bool SetTypeFlag(uint bulletin_id, DbBulletinType type, int flags)
 {
     return(Context.Connection.Execute("UPDATE fso_bulletin_posts SET flags = @flags, type = @type WHERE bulletin_id = @bulletin_id",
                                       new { bulletin_id, type = type.ToString(), flags }) > 0);
 }