예제 #1
0
        public async Task <bool> ConfirmImg(string imgId)
        {
            try
            {
                var    repo = uow.ImageRepo();
                tblImg temp = new tblImg();
                foreach (var item in await repo.GetEntities())
                {
                    if (item.ImgId == imgId)
                    {
                        temp = item;
                        break;
                    }
                }
                if (temp != null)
                {
                    temp.IsValid = true;
                    var filter = Builders <tblImg> .Filter.Eq(x => x.ImgId, imgId);

                    return(await repo.UpdateEntities(filter, temp));
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
        public async Task <bool> IncreaseView(string imgId)
        {
            try
            {
                var    repo = uow.ImageRepo();
                tblImg tbl  = new tblImg();
                foreach (var item in await repo.GetEntities())
                {
                    if (item.ImgId == imgId)
                    {
                        tbl = item;
                    }
                }
                tbl.View += 1;
                var filter = Builders <tblImg> .Filter.Eq(x => x.ImgId, imgId);

                return(await repo.UpdateEntities(filter, tbl));
            }
            catch
            {
                return(false);
            }
        }