public override OperationResult Execute(skiiiEntities entities)
        {
            IQueryable <Post> iePosts = entities.Posts;

            iePosts = iePosts.Where(r => r.idCategory == Criteria.Id);

            IEnumerable <PostDTO> iePostDTO = (from p in iePosts
                                               orderby p.idPost descending
                                               select new PostDTO
            {
                Id = p.idPost,
                CategoryName = p.Category.name,
                heading = p.heading,
                paragraph = p.paragraph,
                publish = p.publish,
                src = p.Image.src,
                username = p.AspNetUser.UserName
            }).Take(3);
            OperationResult result = new OperationResult();

            result.Items  = iePostDTO.ToArray();
            result.Status = true;

            return(result);
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            IQueryable <Category> iqCategory = entities.Categories;

            if (Criteria.Id != 0)
            {
                iqCategory = iqCategory.Where(r => r.idCategory == Criteria.Id);
            }

            IEnumerable <CategoryDTO> ieCat =
                from c in iqCategory
                select new CategoryDTO
            {
                Id     = c.idCategory,
                Name   = c.name,
                Number = c.Posts.Count
            };

            OperationResult result = new OperationResult
            {
                Items  = ieCat.ToArray(),
                Status = true
            };

            return(result);
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            IQueryable <Contact> iqContact = entities.Contacts;

            if (Criteria.Id != 0)
            {
                iqContact = iqContact.Where(r => r.idContact == Criteria.Id);
            }

            IEnumerable <ContactDTO> ieContact =
                from c in iqContact
                select new ContactDTO
            {
                Id      = c.idContact,
                Uuid    = c.AspNetUser.UserName,
                message = c.message,
                date    = c.date
            };


            OperationResult result = new OperationResult();

            result.Items  = ieContact.ToArray();
            result.Status = true;

            return(result);
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            Category cat = new Category();

            cat.name = this.Cat.Name;

            entities.Categories.Add(cat);
            entities.SaveChanges();

            return(base.Execute(entities));
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            var contact = new Contact();

            contact.idUser  = this.DTO.Uuid;
            contact.message = this.DTO.message;

            entities.Contacts.Add(contact);
            entities.SaveChanges();

            return(base.Execute(entities));
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            Category cat = entities.Categories.Where(r => r.idCategory == Cat.Id).FirstOrDefault();

            if (cat != null)
            {
                cat.name = Cat.Name;
                entities.SaveChanges();
                return(base.Execute(entities));
            }

            OperationResult result = new OperationResult();

            result.Status  = false;
            result.Message = "Kategorija ne postoji";
            return(result);
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            Post postzabrisanje = entities.Posts.Where(p => p.idPost == idzabriranje).FirstOrDefault();

            if (postzabrisanje != null)
            {
                entities.Posts.Remove(postzabrisanje);
                entities.SaveChanges();
                return(base.Execute(entities));
            }
            else
            {
                OperationResult result = new OperationResult();
                result.Status  = false;
                result.Message = "Doslo je do greske, post ne postoji u bazi.";
                return(result);
            }
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            Category cat = entities.Categories.Where(p => p.idCategory == IdzaBrisanje).FirstOrDefault();

            if (cat != null)
            {
                entities.Categories.Remove(cat);
                entities.SaveChanges();
                return(base.Execute(entities));
            }
            else
            {
                OperationResult result = new OperationResult();
                result.Status  = false;
                result.Message = "Doslo je do greske. Odredjeni postovi se nalaze u kategoriji";
                return(result);
            }
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            IEnumerable <HeaderDTO> ieHeader =
                (from h in entities.Headers
                 orderby h.idHeader descending
                 select new HeaderDTO
            {
                Id = h.idHeader,
                heading = h.heading,
                src = h.Image.src
            }).Take(1);

            OperationResult result = new OperationResult
            {
                Status = true,
                Items  = ieHeader.ToArray()
            };

            return(result);
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            IQueryable <Post> iqPost = entities.Posts;

            if (Criteria.Id != 0)
            {
                iqPost = iqPost.Where(r => r.idPost == Criteria.Id);
            }
            if (!String.IsNullOrEmpty(Criteria.Uuid))
            {
                iqPost = iqPost.Where(r => r.idUser == Criteria.Uuid);
            }
            IEnumerable <PostDTO> iePosts =
                (from p in iqPost
                 orderby p.idPost descending
                 select new PostDTO
            {
                Id = p.idPost,
                CategoryName = p.Category.name,
                heading = p.heading,
                paragraph = p.paragraph,
                publish = p.publish,
                src = p.Image.src,
                username = p.AspNetUser.UserName,
                ImageAbout = p.ImageAbout,
                paragraph2 = p.paragraph2
            }).Take(3);

            var e = iqPost.Count();


            OperationResult result = new OperationResult
            {
                Items  = iePosts.ToArray(),
                Status = true,
                Broj   = e
            };

            return(result);
        }
        public override OperationResult Execute(skiiiEntities entities)
        {
            var slika = new Image();

            slika.src = this.DTO.src;

            Post post = new Post();

            post.Image = slika;

            post.heading    = DTO.heading;
            post.idCategory = 4;
            post.idUser     = DTO.Uuid;
            post.ImageAbout = DTO.ImageAbout;
            post.paragraph  = DTO.paragraph;
            post.paragraph2 = DTO.paragraph2;
            post.Image      = slika;
            entities.Images.Add(slika);
            entities.Posts.Add(post);
            entities.SaveChanges();


            return(base.Execute(entities));
        }
Exemplo n.º 12
0
 public abstract OperationResult Execute(skiiiEntities entities);