示例#1
0
        public async Task <OperationDetails> DeleteBrandPhoneAsync(BrandPhoneDTO brandPhoneDTO)
        {
            if (brandPhoneDTO == null)
            {
                return(new OperationDetails("Brand is null", false));
            }
            _database.brandPhoneRepository.Delete(_mapper.Map <BrandPhone>(brandPhoneDTO));
            await _database.SaveAsync();

            return(new OperationDetails("Brand is deleted!", true));
        }
示例#2
0
        public async Task <OperationDetails> EditPhoneBrandAsync(BrandPhoneDTO brandPhoneDTO)
        {
            if (brandPhoneDTO == null)
            {
                return(new OperationDetails("Brand is null", false));
            }
            var brandPhone = await _database.brandPhoneRepository.GetByIdAsync(brandPhoneDTO.BrandPhoneId);

            if (brandPhone == null)
            {
                return(new OperationDetails("Brand with this id is null!", false));
            }
            _database.brandPhoneRepository.Update(_mapper.Map(brandPhoneDTO, brandPhone));
            await _database.SaveAsync();

            return(new OperationDetails("Brand with this id is updated", true));
        }
示例#3
0
        public async Task <OperationDetails> CreateBrandPhoneAsync(BrandPhoneDTO brandPhoneDTO)
        {
            if (brandPhoneDTO == null)
            {
                return(new OperationDetails("Brand Phone is NULL!!", false));
            }

            var brandPhone = await _database.brandPhoneRepository.GetWhereAsync(u => u.BrandName == brandPhoneDTO.BrandName);

            if (brandPhone.Count > 0)
            {
                return(new OperationDetails("Brand with this name already is exist", false));
            }

            _database.brandPhoneRepository.Create(_mapper.Map <BrandPhone>(brandPhoneDTO));
            await _database.SaveAsync();

            return(new OperationDetails("Brand is created!", true));
        }