Ejemplo n.º 1
0
        public Boolean ApagarAutor(PracticesAuthorsVM objeto)
        {
            var practicesAuthorsEntity = new PracticesAuthorsEntity();

            practicesAuthorsEntity.Id = objeto.Id;
            _repositoryPracticesAuthors.Apagar(practicesAuthorsEntity);
            _repositoryPracticesAuthors.Context.SaveChanges();
            return(true);
        }
Ejemplo n.º 2
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);
            }
        }