public void AddDeskComputerBind(AddDeskCompBM bind)
        {
            DeskComputers deskComputer = Mapper.Map <AddDeskCompBM, DeskComputers>(bind);

            Context.Items.Add(deskComputer);
            Context.SaveChanges();
        }
Exemplo n.º 2
0
        public DetailsDescCompVM GetDetailNotebookVM(int id)
        {
            DeskComputers deskComputer = Context.Items.OfType <DeskComputers>().FirstOrDefault(desk => desk.Id == id);

            DetailsDescCompVM vm = Mapper.Map <DeskComputers, DetailsDescCompVM>(deskComputer);

            return(vm);
        }
Exemplo n.º 3
0
        public AllCommentVm GetAllComents(int Id)
        {
            DeskComputers deskComputer = Context.Items.OfType <DeskComputers>().FirstOrDefault(desk => desk.Id == Id);


            IEnumerable <Comment> comments = deskComputer.Comments;

            IEnumerable <CommentVm> allCommentsVM = Mapper.Map <IEnumerable <Comment>, IEnumerable <CommentVm> >(comments);

            AllCommentVm vm = new AllCommentVm()
            {
                AllComments = allCommentsVM
            };


            return(vm);
        }
Exemplo n.º 4
0
        public void AddCommentToProduct(int id, string userName, AddCommentBM bind)
        {
            DeskComputers computer = Context.Items.OfType <DeskComputers>().FirstOrDefault(desk => desk.Id == id);

            Customer customer = Context.Customers.FirstOrDefault(cust => cust.User.UserName == userName);

            ApplicationUser user = Context.Users.FirstOrDefault(user1 => user1.UserName == userName);

            Comment comment = new Comment()
            {
                PersonName = user.Name,
                Date       = DateTime.Now,
                Content    = bind.Content
            };

            computer.Comments.Add(comment);
            Context.SaveChanges();
        }