public ServiceProviderDTO Map(ServiceProvider serviceProviderEntity) { if (serviceProviderEntity == null) return null; var serviceProviderDto = Mapper.Map<ServiceProvider, ServiceProviderDTO>(serviceProviderEntity); return serviceProviderDto; }
private async void Save() { if (Validate()) { MessageBox.Show("Please fill in the required fields",PageTitle, MessageBoxButton.OK, MessageBoxImage.Warning); return; } using (var c = NestedContainer) { var serviceProvider = Using<IServiceProviderRepository>(c).GetById(Id); if (serviceProvider == null) { serviceProvider = new ServiceProvider(Id); } serviceProvider.Code = Code; serviceProvider.Name = Name; serviceProvider.IdNo = IdNo; serviceProvider.PinNo = PinNo; serviceProvider.MobileNumber = MobileNumber; serviceProvider.AccountNumber = AccountNumber; serviceProvider.AccountName = AccountName; serviceProvider.Bank = SelectedBankOne; serviceProvider.BankBranch = SelectedBankBranch; serviceProvider.Gender = SelectedGender; serviceProvider._Status = EntityStatus.Active; var response = await Using<IDistributorServiceProxy>(c).ServiceProviderSaveAsync(serviceProvider); if (!response.Success) { MessageBox.Show(response.ErrorInfo, "Agrimangr: Manage Service Provider ", MessageBoxButton.OK, MessageBoxImage.Information); } //var contact = Using<IContactRepository>(c).GetByContactOwnerId(Id); //if(contact==null) //{ // contact = new Contact(Guid.NewGuid()); //} //contact.Firstname = Name; //contact.MobilePhone = MobileNumber; //contact.PhysicalAddress = PhysicalAddress; //contact.PostalAddress = PostalAddress; //contact.Email = Email; //contact.HomePhone = PhoneNumber; //contact.BusinessPhone = BusinessNumber; //contact.Fax = FaxNumber; //contact.ContactOwnerMasterId = Id; //var listContact = new List<ContactItem>(); //listContact.Add(Map(contact)); //var cresponse = await Using<IDistributorServiceProxy>(c).ContactsAddAsync(listContact); //if (!string.IsNullOrWhiteSpace(cresponse.ErrorInfo)) //{ // MessageBox.Show(cresponse.ErrorInfo, "Agrimangr: Manage Service Provider ", // MessageBoxButton.OK, MessageBoxImage.Information); //} if (response.Success) { MessageBox.Show("Service Provider Successfully Added", "Agrimangr: Manage Service Provider ", MessageBoxButton.OK, MessageBoxImage.Information); SendNavigationRequestMessage(new Uri("/Views/Admin/FarmActivities/ServiceProviders/ListServiceProviders.xaml", UriKind.Relative)); } } }
public async Task<ResponseBool> ServiceProviderSaveAsync(ServiceProvider serviceProvider) { ResponseBool _response = new ResponseBool { Success = false, ErrorInfo = "" }; var dto = _masterDataToDTOMapping.Map(serviceProvider); if (dto == null) return _response; string url = string.Format("api/pushmasterdata/serviceprovider/save"); var httpClient = setupHttpClient(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var response = await httpClient.PostAsJsonAsync(url, dto); _response = await response.Content.ReadAsAsync<ResponseBool>(); } catch (Exception ex) { _response.ErrorInfo = "Failed to save service provider DTO.\n" + ex.Message; _log.Error("Failed to save service provider DTO", ex); } return _response; }
protected Guid AddServiceProvider(string name, string code, string mobile, string pin, string idNo, string accountName,string accountNumber,Gender gender,string description, Guid bankId,Guid bankBranchId) { var provider = new ServiceProvider(Guid.NewGuid()) {Name = name, Code = code, MobileNumber = mobile, PinNo = pin, IdNo = idNo, AccountName = accountName, AccountNumber = accountNumber, Gender = gender, Bank =_bankRepository.GetById(bankId), BankBranch =_bankBranchRepository.GetById(bankBranchId), Description = description }; provider._SetStatus(EntityStatus.Active); return _ServiceProviderRepository.Save(provider); }