Ejemplo n.º 1
0
        public List <PracticesVM> ListarPractice(PracticesVM objeto)
        {
            var LisPracticesEntity = new List <PracticesEntity>();

            #region Listagem
            if (objeto.Name != null)
            {
                LisPracticesEntity = _repositoryPractices.Listar(o => o.Name.ToUpper().Contains(objeto.Name.ToUpper()));
            }
            else
            {
                LisPracticesEntity = _repositoryPractices.Listar();
            }
            #endregion

            if (LisPracticesEntity.Count() == 0)
            {
                return(null);
            }

            var listaPracticeVM = new List <PracticesVM>();
            var practicesVM     = new PracticesVM();

            foreach (var item in LisPracticesEntity)
            {
                practicesVM.AuthorsPractice    = EntityToVMPracticesAuthors(item.Id);
                practicesVM.ContribuitionTypes = item.ContribuitionTypes;
                practicesVM.Description        = item.Description;
                practicesVM.Id     = item.Id;
                practicesVM.IdUser = item.IdUser;
                practicesVM.Link   = item.Link;
                practicesVM.Name   = item.Name;
                practicesVM.OrganizationContext   = item.OrganizationContext;
                practicesVM.ReferencesDescribing  = item.ReferencesDescribing;
                practicesVM.SeKnowLedge           = item.SeKnowLedge;
                practicesVM.TypesAiMlApplications = item.TypesAiMlApplications;
                listaPracticeVM.Add(practicesVM);
                practicesVM = new PracticesVM();
            }

            return(listaPracticeVM);
        }
Ejemplo n.º 2
0
 public Boolean Post([FromBody] PracticesVM objeto)
 {
     return(_practicesBll.SalvarPractices(objeto));
 }
Ejemplo n.º 3
0
 public List <PracticesAnexoVM> GetPracticesAnexo([FromQuery] PracticesVM objeto)
 {
     return(_practicesBll.EntityToVMPracticesAnexo(objeto.Id));
 }
Ejemplo n.º 4
0
 public List <PracticesVM> Get([FromQuery] PracticesVM objeto)
 {
     return(_practicesBll.ListarPractice(objeto));
 }
Ejemplo n.º 5
0
        public Boolean SalvarPractices(PracticesVM objeto)
        {
            try
            {
                #region Salvar Practice

                var practicesEntity = new PracticesEntity {
                    Id                    = objeto.Id,
                    Name                  = objeto.Name,
                    Description           = objeto.Description,
                    TypesAiMlApplications = objeto.TypesAiMlApplications,
                    OrganizationContext   = objeto.OrganizationContext,
                    SeKnowLedge           = objeto.SeKnowLedge,
                    ContribuitionTypes    = objeto.ContribuitionTypes,
                    Link                  = objeto.Link,
                    ReferencesDescribing  = objeto.ReferencesDescribing,
                    IdUser                = objeto.IdUser
                };

                #region Add Or Update
                if (objeto.Id > 0)
                {
                    _repositoryPractices.Update(practicesEntity);
                }
                else
                {
                    _repositoryPractices.Salvar(practicesEntity);
                }
                #endregion

                _repositoryPractices.Context.SaveChanges();
                objeto.Id = practicesEntity.Id;

                #endregion

                #region Salvar Anexos Practices
                if (objeto.AnexosPractice.Count() > 0)
                {
                    foreach (var item in objeto.AnexosPractice)
                    {
                        var practicesAnexoEntity = new PracticesAnexoEntity();

                        practicesAnexoEntity.Id            = item.Id;
                        practicesAnexoEntity.Name          = item.Name;
                        practicesAnexoEntity.ObjetoAnexo   = item.ObjetoAnexo;
                        practicesAnexoEntity.IdPractice    = practicesEntity.Id;
                        practicesAnexoEntity.ExtensaoAnexo = item.ExtensaoAnexo;

                        #region Add Or Update
                        if (item.Id > 0)
                        {
                            _repositoryPracticesAnexo.Update(practicesAnexoEntity);
                        }
                        else
                        {
                            _repositoryPracticesAnexo.Salvar(practicesAnexoEntity);
                        }
                        _repositoryPracticesAnexo.Context.SaveChanges();
                        #endregion

                        practicesAnexoEntity = new PracticesAnexoEntity();
                    }
                }
                #endregion

                #region Salvar Author Practices
                if (objeto.AuthorsPractice.Count() > 0)
                {
                    foreach (var item in objeto.AuthorsPractice)
                    {
                        var practicesAuthorsEntity = new PracticesAuthorsEntity();

                        practicesAuthorsEntity.Id         = item.Id;
                        practicesAuthorsEntity.IdPractice = practicesEntity.Id;
                        practicesAuthorsEntity.IdUser     = item.IdUser;

                        #region Add Or Update
                        if (item.Id > 0)
                        {
                            _repositoryPracticesAuthors.Update(practicesAuthorsEntity);
                        }
                        else
                        {
                            _repositoryPracticesAuthors.Salvar(practicesAuthorsEntity);
                        }
                        _repositoryPracticesAnexo.Context.SaveChanges();
                        #endregion

                        practicesAuthorsEntity = new PracticesAuthorsEntity();
                    }
                }
                #endregion

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }