示例#1
0
        public bool Save(Marca entity)
        {
            bool result = false;

            try
            {
                using (var unitOfWork = new AppUnitOfWork())
                {
                    if (entity.MarcaID == 0)
                    {
                        unitOfWork.MarcaRepository.Add(entity);
                    }
                    else
                    {
                        unitOfWork.MarcaRepository.Update(entity);
                    }
                    unitOfWork.Complete();
                }

                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }
        public bool Save(Categoria entity)
        {
            bool result = false;

            try
            {
                using (var unitOfWork = new AppUnitOfWork())
                {
                    if (entity.CategoriaID == 0)//registro nuevo
                    {
                        unitOfWork.CategoriaRepository.Add(entity);
                    }
                    else
                    {
                        unitOfWork.CategoriaRepository.Update(entity);
                    }

                    unitOfWork.Complete();
                }

                result = true;
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(result);
        }
示例#3
0
        public bool Save(Comentario comentario)
        {
            bool result = false;

            try
            {
                using (var unitOfWork = new AppUnitOfWork())
                {
                    if (comentario.ComentarioID == 0)
                    {
                        unitOfWork.ComentarioRepository.Add(comentario);
                    }
                    else
                    {
                        unitOfWork.ComentarioRepository.Update(comentario);
                    }
                    unitOfWork.Complete();
                }
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }
示例#4
0
        public bool Save(Producto entity)
        {
            bool result = false;

            try
            {
                using (var unitOfWork = new AppUnitOfWork())
                {
                    if (entity.ProductoID == 0)//Cuando es nuevo registro
                    {
                        unitOfWork.ProductoRepository.Add(entity);
                    }
                    else
                    {
                        unitOfWork.ProductoRepository.Update(entity);
                    }
                    unitOfWork.Complete();
                }

                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
        public bool Save(Producto entity)
        {
            bool result = false;

            try
            {
                using (var unitOfWork = new AppUnitOfWork())
                {
                    if (entity.ProductoID == 0)
                    {
                        unitOfWork.ProductoRepository.Add(entity);
                    }
                    else
                    {
                        unitOfWork.ProductoRepository.Update(entity);
                    }
                    unitOfWork.Complete();
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
 public void Guardar(Comentario entity)
 {
     using (var unitOfWork = new AppUnitOfWork())
     {
         unitOfWork.ComentarioRepository.Add(entity);
         unitOfWork.Complete();
     }
 }
        public void ExistenArtistas()
        {
            using (var unitOfWork = new AppUnitOfWork())
            {
                var cantRows = unitOfWork.ArtistRepository.Count();

                unitOfWork.Complete();

                Assert.IsTrue(cantRows > 0);
            }
        }
        public void Insert()
        {
            int result = 0;

            using (var unitOfWOrk = new AppUnitOfWork())
            {
                Artist objArtist = new Artist();
                objArtist.Name = "Artist" + Guid.NewGuid();
                unitOfWOrk.ArtistRepository.Add(objArtist);
                result = unitOfWOrk.Complete();
            }
            Assert.IsTrue(result > 0);
        }
        public void Remove()
        {
            int result = 0;

            using (var unitOfWOrk = new AppUnitOfWork())
            {
                Artist objArtist = new Artist();
                objArtist.ArtistId = 291;
                unitOfWOrk.ArtistRepository.Remove(objArtist);
                result = unitOfWOrk.Complete();
            }
            Assert.IsTrue(result > 0);
        }
示例#10
0
        public int InsertArtist(Artist entity)
        {
            var result = 0;

            using (var uw = new AppUnitOfWork())
            {
                uw.ArtistRepositorys.Add(entity);
                uw.Complete();

                result = entity.ArtistId;
            }
            return(result);
        }
示例#11
0
        public bool DeleteArtist(Artist entity)
        {
            var result = false;

            using (var uw = new AppUnitOfWork())
            {
                uw.ArtistRepositorys.Remove(entity);
                uw.Complete();

                result = true;
            }
            return(result);
        }
示例#12
0
        public void Delete()
        {
            int result = 0;

            using (var unitOfWork = new AppUnitOfWork())
            {
                var entity = new Artist();
                entity.ArtistId = 289;
                unitOfWork.ArtistRepository.Remove(entity);
                result = unitOfWork.Complete();
            }
            Assert.IsTrue(result > 0);
        }
示例#13
0
        public void Insert()
        {
            int result = 0;

            using (var unitOfWork = new AppUnitOfWork())
            {
                var entity = new Artist();
                entity.Name = "Artist-" + Guid.NewGuid();
                unitOfWork.ArtistRepository.Add(entity);
                result = unitOfWork.Complete();
            }
            Assert.IsTrue(result > 0);
        }
示例#14
0
        public bool UpdateArtist(Artist entity)
        {
            bool result = false;

            using (var uw = new AppUnitOfWork())
            {
                uw.ArtistRepository.Update(entity);
                uw.Complete();

                result = true;
            }

            return(result);
        }
示例#15
0
        public void InsertAtist()
        {
            var result = false;

            using (var uw = new AppUnitOfWork())
            {
                var newArtist = new Artist()
                {
                    Name = "Artist Nuevo"
                };
                uw.ArtistRepositorys.Add(newArtist);

                result = uw.Complete() > 0;
            }

            Assert.IsTrue(result);
        }
        public void InsertAlbum()
        {
            var result = false;

            using (var uw = new AppUnitOfWork())
            {
                var newArtist = new Artist()
                {
                    Name = "Artista nuevo"
                };
                var newAlbum = new Album()
                {
                    Title  = "Album nuevo",
                    Artist = newArtist
                };

                uw.AlbumRepository.Add(newAlbum);

                result = uw.Complete() > 0;
            }

            Assert.IsTrue(result);
        }