Ejemplo n.º 1
0
        public async Task <ActionResult> PostBrand(BrandQuery brand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (brand.Logo != null && !Enum.GetNames(typeof(ImageExt))
                .Contains(System.IO.Path.GetExtension(brand.Logo.FileName)
                          .Trim().ToUpper()))
            {
                return(BadRequest("File not supported"));
            }
            var dbBrand = await _repo.AddBrand(brand);

            if (dbBrand != null)
            {
                if (brand.Logo != null)
                {
                    await _repo.AssignLogo(brand.Logo, dbBrand.Id);
                }
                if (brand.Tags.Count > 0)
                {
                    await _repo.AssignTags(brand.Tags, dbBrand.Id);
                }
            }

            return(CreatedAtAction("GetBrand", new { id = dbBrand.Id }, dbBrand));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> AddBrand(Brand entity)
        {
            await _brandRepository.AddBrand(entity);

            return(Ok(entity));
        }
Ejemplo n.º 3
0
        public void AddBrand(Entity.Brand brand)
        {
            BrandRepository repository = new BrandRepository();

            repository.AddBrand(brand);
        }
Ejemplo n.º 4
0
        public ActionResult Add(Brand brand)
        {
            repository.AddBrand(brand);

            return(RedirectToAction("Index"));
        }