コード例 #1
0
        public ActionResult GetPortfolioByUserAnId(string id, string userid)
        {
            ZonaFl.Persistence.Entities.PortFolio portf     = null;
            Business.SubSystems.SCategory         scategory = new Business.SubSystems.SCategory();
            ZonaFl.Business.SubSystems.SPortfolio portF     = new Business.SubSystems.SPortfolio();
            portf = portF.GetPortFolioByUserId(id, userid);
            if (portf == null)
            {
                portf = new Persistence.Entities.PortFolio();
            }
            Models.PortFolio porfM = new Models.PortFolio();
            porfM.InjectFrom(portf);
            var catp = scategory.FindCategoryById(portf.CategoriaId);

            if (catp != null)
            {
                porfM.Categoria = catp.Name;
            }
            return(Json(porfM, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult EditById(string id)
        {
            //if (SessionBag.Current.Logout != null && SessionBag.Current.Logout)
            //{

            //    SessionBag.Current.Logout = false;
            //    return RedirectToAction("Index", "Home");
            //}
            ZonaFl.Persistence.Entities.AspNetUsers useru = null;
            ZonaFl.Business.SubSystems.SUser        usern = new Business.SubSystems.SUser();
            useru = usern.GetUserById(new Guid(id));

            if (SessionBag.Current.User == null)
            {
                SessionBag.Current.User = useru;
            }
            ZonaFl.Business.SubSystems.SCategory scategory = new Business.SubSystems.SCategory();
            RegisterBindingModel regbm = new RegisterBindingModel();

            regbm.InjectFrom(useru);
            regbm.Skills = useru.Skills.Select(e => new ZonaFl.Models.Skill().InjectFrom(e)).Cast <ZonaFl.Models.Skill>().ToList();
            if (useru.Companies.FirstOrDefault() != null)
            {
                regbm.Company = useru.Companies.Select(e => new ZonaFl.Models.Company().InjectFrom(e)).Cast <ZonaFl.Models.Company>().ToList();
            }

            List <Models.Category> categorysm = new List <Models.Category>();

            foreach (var skill in useru.Skills)
            {
                Models.Category categorym = new Models.Category();
                if (categorysm.Find(e => e.Id == skill.CategoryId) == null)
                {
                    var category = scategory.FindCategoryById(skill.CategoryId);
                    categorym.InjectFrom(category);
                    categorysm.Add(categorym);
                }
            }


            regbm.Categories = categorysm;
            //regbm.Categories.ForEach(e => e.Skills = useru.Skills.Select(y => new ZonaFl.Models.Skill().InjectFrom(y)).Cast<ZonaFl.Models.Skill>().ToList());
            ViewBag.User      = useru.UserName;
            ViewBag.IdUser    = useru.Id;
            ViewBag.ImageUser = useru.Image;
            ViewBag.EmailUser = useru.Email;
            //ViewBag.Country = useru.Country;
            ZonaFl.Business.SubSystems.SCountry scountry = new Business.SubSystems.SCountry();


            var itemciudad = scountry.FindCityByName(useru.City);
            var item       = scountry.FindCountrybyName(useru.Country);

            var items = item != null?scountry.FindAll().Where(e => e.Id != item.Id).ToList() : scountry.FindAll();

            if (item != null)
            {
                items.Insert(0, item);
            }

            var countries = new SelectList(items, "ID", "Name").ToList();

            ViewBag.Countrysel = item != null ? item.Id: items.First().Id;
            var countryfirst = scountry.FindFirstCityByCountry(int.Parse(ViewBag.Countrysel.ToString()));

            ViewBag.Ciudadsel = string.IsNullOrEmpty(itemciudad.Name) ? countryfirst.Name : itemciudad.Name;
            ViewBag.Country   = countries;

            if (regbm.Company == null)
            {
                regbm.Company = new List <Models.Company>();
                regbm.Company.Add(new Models.Company());
            }

            if (regbm.PhoneNumber == null)
            {
                regbm.PhoneNumber = regbm.Company.FirstOrDefault().Telefono;
            }
            ViewBag.Title = "Contratante";
            //TempData["SkillsUser"] = regbm.Skills;
            return(View("Edit", regbm));
        }
コード例 #3
0
        public ActionResult EditById(string id)
        {
            ZonaFl.Persistence.Entities.AspNetUsers useru     = null;
            ZonaFl.Business.SubSystems.SUser        usern     = new Business.SubSystems.SUser();
            ZonaFl.Business.SubSystems.SCategory    scategory = new Business.SubSystems.SCategory();

            ZonaFl.Business.SubSystems.SCountry scountry = new Business.SubSystems.SCountry();

            useru = usern.GetUserById(new Guid(id));
            if (SessionBag.Current.User == null)
            {
                SessionBag.Current.User = useru;
            }

            RegisterBindingModel regbm = new RegisterBindingModel();

            regbm.InjectFrom(useru);
            regbm.Skills     = useru.Skills.Select(e => new ZonaFl.Models.Skill().InjectFrom(e)).Cast <ZonaFl.Models.Skill>().ToList();
            regbm.Categories = useru.Skills.Select(e => new ZonaFl.Models.Category().InjectFrom(scategory.FindCategoryById(e.CategoryId))).Cast <ZonaFl.Models.Category>().GroupBy(t => t.Id).Select(g => g.First()).ToList();
            regbm.Categories.ForEach(e => e.Skills = useru.Skills.Where(w => w.CategoryId == e.Id).Select(y => new ZonaFl.Models.Skill().InjectFrom(y)).Cast <ZonaFl.Models.Skill>().ToList());

            ViewBag.CountAllCategories = regbm.Skills != null?regbm.Skills.Where(e => e.Visible).Count() : 0;

            //var query = regbm.Categories.Select(s => s.Skills.Where(v => v.Visible).GroupBy(c => c.CategoryId)).SelectMany(r => r).ToList();


            var query = from skill in regbm.Skills
                        where skill.Visible
                        group skill by skill.CategoryId
                        into grouping
                        select new { Key = grouping.Key, Count = grouping.Count() };

            foreach (var VARIABLE in query)
            {
                regbm.GetType().GetProperty("Count" + VARIABLE.Key.ToString()).SetValue(regbm, VARIABLE.Count);
            }

            ViewBag.Skills     = regbm.Skills;
            ViewBag.Categories = regbm.Categories;
            ViewBag.User       = useru.UserName;
            ViewBag.IdUser     = useru.Id;
            ViewBag.ImageUser  = useru.Image;
            Persistence.Entities.City    itemciudad = null;
            Persistence.Entities.Country item       = null;
            if (useru.City != null)
            {
                itemciudad = scountry.FindCityByName(useru.City);
            }
            else
            {
                itemciudad = scountry.FindCityByName("Bogota");
            }
            if (useru.Country != null)
            {
                item = scountry.FindCountrybyName(useru.Country);
            }
            else
            {
                item = scountry.FindCountrybyName("Colombia");
            }
            List <SelectListItem> countries = null;

            if (item != null)
            {
                var items = scountry.FindAll().Where(e => e.Id != item.Id).ToList();

                items.Insert(0, item);
                countries = new SelectList(items, "ID", "Name").ToList();
            }
            else
            {
                var items = scountry.FindAll();
                countries = new SelectList(items, "ID", "Name").ToList();
                item      = items.FirstOrDefault();
            }

            ViewBag.Countrysel     = item.Id;
            ViewBag.Ciudadsel      = itemciudad.Name;
            ViewBag.Country        = countries;
            TempData["SkillsUser"] = regbm.Skills;
            ViewBag.Title          = "Freelance";
            return(View("Edit", regbm));
        }