Ejemplo n.º 1
0
        public string CreateBrand(Brand brand)
        {
            try
            {
                if (brand != null)
                {
                    var res = _DbContext.Brands.Where(x => x.Name == brand.Name).FirstOrDefault();
                    if (res != null)
                    {
                        return("already");
                    }
                    Database.Brand entity = new Database.Brand();
                    entity = AutoMapperConfig.BrandToDbBrandMapper.Map <Database.Brand>(brand);

                    _DbContext.Brands.Add(entity);
                    _DbContext.SaveChanges();
                    return("created");
                }
                return("null");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
        public bool IsActive(int BrandId)
        {
            Database.Brand entity = new Database.Brand();

            if (entity.IsActive)
            {
                return(true);
            }
            return(false);
        }
        public Brands getBrand(int BrandId)
        {
            Database.Brand entity = new Database.Brand();
            entity = dbcontext.Brands.Find(BrandId);

            var config = new MapperConfiguration(cfg => cfg.CreateMap <Database.Brand, Brands>());
            var mapper = new Mapper(config);

            Brands brand = mapper.Map <Brands>(entity);

            return(brand);
        }
        public string DeleteBrand(int BrandId)
        {
            Database.Brand entity = new Database.Brand();
            entity = dbcontext.Brands.Find(BrandId);

            if (entity != null)
            {
                dbcontext.Brands.Remove(entity);
                dbcontext.SaveChanges();
                return("Successfully Deleted");
            }
            return("Done");
        }
Ejemplo n.º 5
0
        public Brand GetBrand(int id)
        {
            Brand brand;

            Database.Brand entity = _DbContext.Brands.Find(id);

            if (entity != null)
            {
                brand = AutoMapperConfig.DbBrandToBrandMapper.Map <Brand>(entity);
            }
            else
            {
                brand = new Brand();
            }
            return(brand);
        }
        public string CreateBrand(Brands brand)
        {
            try
            {
                if (brand != null)
                {
                    Database.Brand entity = new Database.Brand();

                    var config = new MapperConfiguration(cfg => cfg.CreateMap <Brands, Database.Brand>());
                    var mapper = new Mapper(config);

                    entity = mapper.Map <Database.Brand>(brand);

                    dbcontext.SaveChanges();

                    return("created");
                }
                return("null");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }