Exemplo n.º 1
0
        public HobbieDomainModel GetHobbieByPersonal(int _id)
        {
            HobbieDomainModel hobbieDomainModel = new HobbieDomainModel();
            tblHobbies        tblHobbies        = new tblHobbies();

            tblHobbies = hobbieRepository.GetAll(p => p.id == _id).FirstOrDefault();

            if (tblHobbies != null)
            {
                hobbieDomainModel.id                = tblHobbies.id;
                hobbieDomainModel.idFrecuencia      = tblHobbies.idFruencia.Value;
                hobbieDomainModel.idHobbie          = tblHobbies.idHobbie.Value;
                hobbieDomainModel.idPersonal        = tblHobbies.idPersonal.Value;
                hobbieDomainModel.strTiempoPractica = tblHobbies.strTiempoPractica;
                hobbieDomainModel.Frecuencia        = new FrecuenciaDomainModel
                {
                    StrDescripcion = tblHobbies.catFrecuencia.strDescripcion
                };
                hobbieDomainModel.Hobbies = new HobbiesDomainModel
                {
                    strValor = tblHobbies.CatHobbies.strValor
                };
            }


            return(hobbieDomainModel);
        }
Exemplo n.º 2
0
        public bool AddUpdateHobbie(HobbieDomainModel hobbieDomainModel)
        {
            bool respuesta = false;

            if (hobbieDomainModel.id > 0)
            {
                tblHobbies tblHobbies = hobbieRepository.GetAll(p => p.id == hobbieDomainModel.id).FirstOrDefault();

                if (tblHobbies.tblPersonal != null)
                {
                    tblHobbies.idFruencia        = hobbieDomainModel.idFrecuencia;
                    tblHobbies.idHobbie          = hobbieDomainModel.idHobbie;
                    tblHobbies.idPersonal        = hobbieDomainModel.idPersonal;
                    tblHobbies.strTiempoPractica = hobbieDomainModel.strTiempoPractica;

                    hobbieRepository.Update(tblHobbies);
                    respuesta = true;
                }
            }
            else
            {
                tblHobbies tblHobbies = new tblHobbies();

                tblHobbies.idFruencia        = hobbieDomainModel.idFrecuencia;
                tblHobbies.idHobbie          = hobbieDomainModel.idHobbie;
                tblHobbies.idPersonal        = hobbieDomainModel.idPersonal;
                tblHobbies.strTiempoPractica = hobbieDomainModel.strTiempoPractica;

                hobbieRepository.Insert(tblHobbies);
                respuesta = true;
            }

            return(respuesta);
        }
Exemplo n.º 3
0
        public List <HobbieDomainModel> GetAllHobbiesByPersonal(int _idPersonal)
        {
            List <HobbieDomainModel> hobbies    = new List <HobbieDomainModel>();
            List <tblHobbies>        tblhobbies = new List <tblHobbies>();

            tblhobbies = hobbieRepository.GetAll(p => p.idPersonal == _idPersonal).ToList();

            foreach (tblHobbies item in tblhobbies)
            {
                HobbieDomainModel hobbieDomainModel = new HobbieDomainModel();

                hobbieDomainModel.id                = item.id;
                hobbieDomainModel.idFrecuencia      = item.idFruencia.Value;
                hobbieDomainModel.idHobbie          = item.idHobbie.Value;
                hobbieDomainModel.idPersonal        = item.idPersonal.Value;
                hobbieDomainModel.strTiempoPractica = item.strTiempoPractica;
                hobbieDomainModel.Hobbies           = new HobbiesDomainModel {
                    strValor = item.CatHobbies.strValor
                };
                hobbieDomainModel.Frecuencia = new FrecuenciaDomainModel {
                    StrDescripcion = item.catFrecuencia.strDescripcion
                };

                hobbies.Add(hobbieDomainModel);
            }

            return(hobbies);
        }
Exemplo n.º 4
0
        public ActionResult UpdateHobbie(HobbieVM hobbieVM)
        {
            if (hobbieVM.id > 0)
            {
                HobbieDomainModel hobbieDomainModel = new HobbieDomainModel();

                AutoMapper.Mapper.Map(hobbieVM, hobbieDomainModel);

                hobbieBusiness.AddUpdateHobbie(hobbieDomainModel);
            }

            return(RedirectToAction("Create", "Hobbie"));
        }
Exemplo n.º 5
0
        public ActionResult DisplayHobbie(int id)
        {
            if (id > 0)
            {
                HobbieDomainModel hobbieDomainModel = hobbieBusiness.GetHobbieByPersonal(id);
                HobbieVM          hobbieVM          = new HobbieVM();

                AutoMapper.Mapper.Map(hobbieDomainModel, hobbieVM);

                return(PartialView("_VerDatos", hobbieVM));
            }

            return(PartialView());
        }
Exemplo n.º 6
0
        public ActionResult GetHobbieDelete(int _id)
        {
            HobbieDomainModel hobbieDomainModel = new HobbieDomainModel();
            HobbieVM          hobbieVM          = new HobbieVM();

            if (_id > 0)
            {
                hobbieDomainModel = hobbieBusiness.GetHobbieByPersonal(_id);

                AutoMapper.Mapper.Map(hobbieDomainModel, hobbieVM);
            }

            return(PartialView("_Eliminar", hobbieVM));
        }
Exemplo n.º 7
0
        public ActionResult Create(HobbieVM hobbieVM)
        {
            if (ModelState.IsValid)
            {
                hobbieVM.idPersonal = SessionPersister.AccountSession.IdPersonal;

                HobbieDomainModel hobbieDomainModel = new HobbieDomainModel();

                AutoMapper.Mapper.Map(hobbieVM, hobbieDomainModel);

                hobbieBusiness.AddUpdateHobbie(hobbieDomainModel);
            }

            return(RedirectToAction("Create", "Hobbie"));
        }
Exemplo n.º 8
0
        public ActionResult GetHobbieUpdate(int _id)
        {
            HobbieDomainModel hobbieDomainModel = new HobbieDomainModel();
            HobbieVM          hobbieVM          = new HobbieVM();

            if (_id > 0)
            {
                hobbieDomainModel = hobbieBusiness.GetHobbieByPersonal(_id);

                AutoMapper.Mapper.Map(hobbieDomainModel, hobbieVM);

                ViewBag.idHobbie     = new SelectList(hobbiesBusiness.GetAllHobbies(), "id", "strValor");
                ViewBag.idFrecuencia = new SelectList(frecuenciaBusiness.GetFrecuencia(), "IdFrecuencia", "StrDescripcion");
            }

            return(PartialView("_Editar", hobbieVM));
        }