public async Task <bool> AddPhoneTypesVM([FromBody] PostPhoneTypesVM vm, int fileType = 0) { if (fileType != 1 && fileType != 2 && fileType != 0) { fileType = 0; } var result = await _phoneBookRepository.AddPhoneTypesVM(vm, fileType); return(result); }
public async Task <bool> AddPhoneTypesVM(PostPhoneTypesVM vm, int fileType) { try { List <PhoneTypesVM> phoneTypesList = await FileHandlers[fileType].GetPhoneTypesVM(); int phonetypeid = phoneTypesList.Count + 1; phoneTypesList.Add(new PhoneTypesVM { Id = phonetypeid, Name = vm.Name }); await FileHandlers[fileType].WritePhoneTypesVM(phoneTypesList); return(true); } catch (Exception ex) { return(false); } }