Ejemplo n.º 1
0
        public async Task <Brand> AddOrUpdate(Brand brand)
        {
            var brandDbo = new BrandDbo();//await _brandRepository.Get(brand.Id);

            brandDbo = _mapper.Map(brand, brandDbo);

            return(_mapper.Map <Brand>(await _brandRepository.AddOrUpdate(brandDbo)));
        }
Ejemplo n.º 2
0
        public async Task <BrandDbo> AddOrUpdate(BrandDbo brand)
        {
            try
            {
                Log.Debug($"{nameof(AddOrUpdate)} called on {nameof(BrandRepository)}");

                _context.Brands.Update(brand);
                brand.Id = await _context.SaveChangesAsync();

                Log.Debug($"Brand saved in method {nameof(AddOrUpdate)} called on {nameof(BrandRepository)}");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Log.Error($"Error in method {nameof(AddOrUpdate)} in {nameof(BrandRepository)}");
            }

            return(brand);
        }
Ejemplo n.º 3
0
        public async Task <BrandDbo> Get(int id)
        {
            BrandDbo item = null;

            try
            {
                Log.Debug($"{nameof(Get)} called on {nameof(BrandRepository)} with param id of \"{id}\"");

                item = await _context.Brands.FirstOrDefaultAsync(x => x.Id == id);

                Log.Debug($"{(item == null ? "0" : "1")} item(s) was found in {nameof(BrandRepository)} for id \"{id}\"");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Log.Error($"Error in method {nameof(Get)} in {nameof(BrandRepository)}", ex);
            }

            return(item);
        }