public ProposalVm GetbyIdVm(int id)
        {
            ProposalVm result;

            try
            {
                var model = _dbContext.Proposals
                            .Include(x => x.ApplicationUser)
                            .Include(x => x.Answers)
                            .First(x => x.Id == id);

                result = new ProposalVm
                {
                    Id = model.Id,
                    ApplicationUserId = model.ApplicationUserId,
                    CreatedAt         = model.CreatedAt,
                    Description       = model.Description,
                    Offer             = model.Offer,
                    ProyectId         = model.ProyectId,
                    Title             = model.Title,
                    UserName          = model.ApplicationUser.Name + " " + model.ApplicationUser.LastName,
                    Answers           = model.Answers
                };
            }
            catch (Exception)
            {
                result = null;
            }
            return(result);
        }
        public IEnumerable <ProposalVm> GetAllVm()
        {
            var result = new List <ProposalVm>();

            try
            {
                var model = _dbContext.Proposals
                            .Include(x => x.ApplicationUser)
                            .Include(x => x.Answers)
                            .Include(x => x.Proyect).ToList();

                foreach (var i in model)
                {
                    var vm = new ProposalVm
                    {
                        Id = i.Id,
                        ApplicationUserId = i.ApplicationUserId,
                        CreatedAt         = i.CreatedAt,
                        Description       = i.Description,
                        Offer             = i.Offer,
                        ProyectId         = i.ProyectId,
                        Title             = i.Title,
                        UserName          = i.ApplicationUser.Name + " " + i.ApplicationUser.LastName
                    };

                    result.Add(vm);
                }
            }
            catch (Exception)
            {
                result = null;
            }
            return(result);
        }
        public IndexVm <ProyectVm> GetAll(int page = 1)
        {
            var result   = new IndexVm <ProyectVm>();
            var proyects = new List <ProyectVm>();

            try
            {
                int quantityOfProyects = 6;
                var model = _dbContext.Proyects.OrderBy(x => x.CreatedAt)
                            .Include(x => x.ApplicationUser)
                            .Include(x => x.Category)
                            .Include(x => x.Proposal)
                            .Skip((page - 1) * quantityOfProyects)
                            .Take(quantityOfProyects).ToList();

                foreach (var i in model)
                {
                    var proposals = new List <ProposalVm>();
                    foreach (var j in i.Proposal)
                    {
                        var vmProposal = new ProposalVm
                        {
                            Id = j.Id,
                            ApplicationUserId = j.ApplicationUserId,
                            CreatedAt         = j.CreatedAt,
                            Description       = j.Description,
                            Offer             = j.Offer,
                            ProyectId         = j.ProyectId,
                            Title             = j.Title,
                            UserName          = j.ApplicationUser.Name + " " + j.ApplicationUser.LastName
                        };
                        proposals.Add(vmProposal);
                    }

                    var vm = new ProyectVm
                    {
                        Id                = i.Id,
                        Title             = i.Title,
                        ApplicationUserId = i.ApplicationUserId,
                        Avatar            = i.ApplicationUser.Avatar,
                        CategoryId        = i.CategoryId,
                        NameCategory      = i.Category.Name,
                        CreatedAt         = Convert.ToDateTime(i.CreatedAt.ToShortTimeString()),
                        Description       = i.Description,
                        Price             = i.Price,
                        //recuerda que mandaras una string
                        Required_Skill = i.Required_Skill,
                        Scope          = i.Scope,
                        Proposal       = proposals,
                        UserName       = i.ApplicationUser.Name + " " + i.ApplicationUser.LastName
                    };
                    proyects.Add(vm);
                }

                var totalOfRegister = proyects.Count();
                result.Entities        = proyects;
                result.ActualPage      = page;
                result.RegisterByPage  = quantityOfProyects;
                result.TotalOfRegister = totalOfRegister;
            }
            catch (Exception)
            {
                result = null;
            }
            return(result);
        }