예제 #1
0
        public async Task <PartialViewResult> AddPhone(AddPhoneInput input)
        {
            PhoneInPersonListDto phoneInPersonList = await _personAppService.AddPhone(input);

            var model = new PhoneRowInPersonListViewModel(phoneInPersonList);

            return(PartialView("_PhoneRowInPersonList", model));
        }
예제 #2
0
        public async Task <PartialViewResult> AddPhone([FromForm] AddPhoneInput input)
        {
            //[FromBody] == contentType: 'application/json',
            //[FromForm] ==contentType: 'application/x-www-form-urlencoded'
            var phoneInPersonList = await _personAppService.AddPhone(input);

            var model = new PhoneRowInPersonListViewModel(phoneInPersonList);

            return(PartialView("_PhoneRowInPersonList", model));
        }
예제 #3
0
        public async Task <PhoneInPersonListDto> AddPhone(AddPhoneInput input)
        {
            var person = _personRepository.Get(input.PersonId);

            var phone = input.MapTo <Phone>();

            person.Phones.Add(phone);

            await CurrentUnitOfWork.SaveChangesAsync();

            return(phone.MapTo <PhoneInPersonListDto>());
        }
예제 #4
0
        public async Task <PhoneInPersonListDto> AddPhone(AddPhoneInput input)
        {
            var person = _personRepository.Get(input.PersonId);
            await _personRepository.EnsureCollectionLoadedAsync(person, p => p.Phones);

            var phone = ObjectMapper.Map <Phone>(input);

            person.Phones.Add(phone);
            //Get auto increment Id of the new Phone by saving to database
            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <PhoneInPersonListDto>(phone));
        }
        public async Task <PhoneInPersonDto> AddPhone(AddPhoneInput input)
        {
            var person = _personRepository.Get(input.PersonId);
            await _personRepository.EnsureCollectionLoadedAsync(person, p => p.Phones);

            var phone = ObjectMapper.Map <Phones.Phone>(input);

            person.Phones.Add(phone);

            /*(Notice that; normally it's not needed to call CurrentUnitOfWork.SaveChangesAsync. It's automatically called at the end of the method.
             * We called it in the method since we need to save entity and get it's Id immediately*/
            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <PhoneInPersonDto>(phone));
            //weiter mit https://www.aspnetzero.com/Documents/Developing-Step-By-Step-Core/#edit-mode-for-phone-numbers
        }
예제 #6
0
        public async Task <PhoneInPersonDto> AddPhone(AddPhoneInput input)
        {
            //// feature check : i.e. you reached call api limit for this type, please extend your user
            //var createdTaskCountInThisMonth = GetCreatedTaskCountInThisMonth();
            //if (createdTaskCountInThisMonth >= FeatureChecker.GetValue("MaxTaskCreationLimitPerMonth").To<int>())
            //{
            //    throw new AbpAuthorizationException("You exceed task creation limit for this month, sorry :(");
            //}

            var person = _personRepository.Get(input.PersonId);
            await _personRepository.EnsureCollectionLoadedAsync(person, p => p.Phones);

            //var phone = Phone.Create(input.PersonId, input.Type, input.Number);
            var phone = ObjectMapper.Map <Phone>(input);

            person.Phones.Add(phone);

            await CurrentUnitOfWork.SaveChangesAsync();

            return(ObjectMapper.Map <PhoneInPersonDto>(phone));
        }