コード例 #1
0
     public bool Equals(DispatchSupplierCityVehicleType other)
     {
         if (ReferenceEquals(null, other)) return false;
         if (ReferenceEquals(this, other)) return true;
 		if (other.Id == 0 && Id == 0)
 			return false;
 		else
 			return other.Id == Id;
     }
コード例 #2
0
        /// <summary>
        /// save the dispatch supplier with all the details, including manager, cities of service and vechiletypes
        /// </summary>
        private void SaveDispatchSupplier()
        {
            if (SelectedSupplier == null) return;

            AddSupplierRequest addSupplierRequest = new AddSupplierRequest();
            addSupplierRequest.Supplier = SelectedSupplier;
            addSupplierRequest.Manager = Manager;
            addSupplierRequest.HasOnlineAccess = HasOnlineAccess;
            addSupplierRequest.ManagerPassword = ManagerPassword;
            IList<DispatchSupplierCity> dispatchSupplierCityList = new List<DispatchSupplierCity>();
            foreach (CitiesOfServiceControlViewModel cityServiceViewModel in CitiesViewModels)
            {
                if (cityServiceViewModel.SelectedCity == null || cityServiceViewModel.SelectedCity.Id <=0) continue;
                DispatchSupplierCity supplierCity = new DispatchSupplierCity();
                supplierCity.AssignByEmail = cityServiceViewModel.AssignByEmail;
                supplierCity.AssignByFax = cityServiceViewModel.AssignByFax;
                supplierCity.AssignByPda = cityServiceViewModel.AssignByPDA;
                supplierCity.AssignByPhone = cityServiceViewModel.AssignByPhone;
                supplierCity.AssignBySms = cityServiceViewModel.AssignBySMS;
                supplierCity.City = cityServiceViewModel.SelectedCity;
                supplierCity.CityId = cityServiceViewModel.SelectedCity.Id;
                supplierCity.ProspectResponseTime = cityServiceViewModel.SelectedProspectResponseTimes != null ? cityServiceViewModel.SelectedProspectResponseTimes.Value : 0;
                supplierCity.QuotationResponseTime = cityServiceViewModel.SelectedQuotationResponseTime != null ? cityServiceViewModel.SelectedQuotationResponseTime.Value : 0;
                foreach (ViewVehicleType viewVehicleType in cityServiceViewModel.VehicleTypes)
                {
                    if (viewVehicleType.IsSelected)
                    {
                        DispatchSupplierCityVehicleType supplierVehicleType = new DispatchSupplierCityVehicleType();
                        supplierVehicleType.SupplierCityId = supplierCity.Id;
                        supplierVehicleType.VehicleTypeId = viewVehicleType.VehicleType.Id;
                        supplierVehicleType.VehicleType = viewVehicleType.VehicleType;
                        supplierVehicleType.TypeId = viewVehicleType.SelectedStatus != null ? viewVehicleType.SelectedStatus.Id : 0;
                        supplierCity.VehicleTypes.Add(supplierVehicleType);
                    }
                }
                dispatchSupplierCityList.Add(supplierCity);
            }
            addSupplierRequest.Cities = dispatchSupplierCityList;
            DispatcherService.BeginAddSupplier(addSupplierRequest, CreateAsyncCallback(ar => DispatcherService.EndAddSupplier(ar),
                response =>
                {
                   
                    if (response.Errors.Count() == 0)
                    {
                        if (OnSupplierAdded != null) OnSupplierAdded(this, EventArgs.Empty);
                        EnableDisableSave(false); //disable the save button to avoid multiple click by users to same the duplicate data
                    }
                    else
                    {
                        ShowErrors(response.Errors);
                        EnableDisableSave(true);
                    }
                 

                }), null);

        }