// ----- Event callbacks private void RemoteClientListenerOnRemoteClientConnected(object sender, RemoteClientConnectedEventArgs args) { var clientViewModel = new ClientViewModel(args.RemoteClient); clientViewModel.StartPing(); _relations.Add(args.RemoteClient, clientViewModel); _synchronizationContext.Post(state => _clients.Add(clientViewModel), null); }
/// <summary> ///initialise lists and view model /// </summary> public Client(ClientViewModel viewModel) { _viewModel = viewModel; _msgIds = new List<string>(); _onlineClients = new Dictionary<ListBoxItem, SharedComponents.Client>(); _messages = new List<string>(); if (!Directory.Exists("Download")) Directory.CreateDirectory("Download"); }
public EditClientDialogViewModel(MainViewModel mainViewModel) { _mainViewModel = mainViewModel; _clientToEdit = new ClientViewModel(mainViewModel.Context.Clients.FirstOrDefault( x => x.ID == mainViewModel.ClientsViewModel.SelectedContragent.ID)); EditClientCommand = new DelegateCommand(EditClient, Validate); FirstName = _clientToEdit.FirstName; LastName = _clientToEdit.LastName; }
public ToPawnProductViewModel(Product product) : base(product) { var orderedTransactions = product.Transactions.OrderBy(x => x.Date); var transactionToPawn = orderedTransactions.LastOrDefault(x => x.TypeID == (int)TranType.ToPawn); if (transactionToPawn != null) { DateTake = transactionToPawn.Date; Client = new ClientViewModel(transactionToPawn.Contragent.Client); SalesmanTake = new SalesmanViewModel(transactionToPawn.Operator.Salesman); } }
public JsonResult CreateClient([DataSourceRequest] DataSourceRequest request, ClientViewModel client) { if (client == null || !ModelState.IsValid) { return Json(new[] { client }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet); } var createdClient = clients.CreateClient(client); var loggedUserId = User.Identity.GetUserId(); Base.CreateActivity(ActivityType.Create, createdClient.Id.ToString(), ActivityTargetType.Client, loggedUserId); return Json(new[] { createdClient }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet); }
public ToRepairProductViewModel(Product product) : base(product) { var orderedTransactions = product.Transactions.OrderBy(x => x.Date); var firstToRepairTransaction = orderedTransactions.FirstOrDefault(x => x.TypeID == (int) TranType.ToRepair); if (firstToRepairTransaction != null && firstToRepairTransaction.Contragent != null && firstToRepairTransaction.Contragent.Client != null) { Client = new ClientViewModel(firstToRepairTransaction.Contragent.Client); } var lastTransaction = orderedTransactions.LastOrDefault(); if (lastTransaction != null) { LastTransactionDate = lastTransaction.Date; LastTransactionSalesman = new SalesmanViewModel(lastTransaction.Operator.Salesman); CurrentRepairer = (lastTransaction.Contragent == null || lastTransaction.Contragent.Repairer == null) ? null : new RepairerViewModel(lastTransaction.Contragent.Repairer); } }
public string ExecuteCommand(ClientViewModel clientViewModel, string[] arguments) { try { var commandName = arguments.First(); var command = _commandLines.FirstOrDefault(x => string.Equals(x.Name, commandName, StringComparison.CurrentCultureIgnoreCase)); if (command == null) { return "Unknown command."; } else { var parameters = Enumerable.Empty<string>(); if (arguments.Length > 1) { parameters = arguments.Skip(1); } return clientViewModel.ExecuteCommand(command, parameters); } } catch (Exception ex) { return ex.Message; } }
public static ClientViewModel ToViewModel(this Client model) { ClientViewModel result = new ClientViewModel(); result.ClientGuid = model.ClientGuid; result.ClientID = model.ClientID; result.ClientName = model.ClientName; result.PhoneNumber = model.PhoneNumber; result.Email = model.Email; result.Address = model.Address; result.CityStateZipGuid = model.CityStateZipGuid; result.PaymentInfoGuid = model.PaymentInfoGuid; result.FederatedID = model.FederatedID; result.FederatedKey = model.FederatedKey; result.FederatedIDProvider = model.FederatedIDProvider; result.Username = model.Username; result.HashedPassword = model.HashedPassword; return result; }
public OpenNewCommandViewModelMessage(ClientViewModel clientViewModel) { ClientViewModel = clientViewModel; }
public ActionResult Report(int clientId, DateTime startDate, DateTime endDate) { var client = clientRepository.First(c => c.Id == clientId); var clientViewModel = new ClientViewModel(client); var model = new CcoReportViewModel(userManager.GetRoles(User.Identity.GetUserId()), clientViewModel); model.Today = serverTime.RequestStarted; model.OnMonth = model.Today.AddMonths(-1); model.OneQuarter = model.Today.AddMonths(-3); model.OneYear = model.Today.AddMonths(-12); model.StartDate = startDate; model.EndDate = endDate; var tableId = client.AnalyticsTableId; var query = new AnalyticQuery { TabelId = tableId, StartDate = startDate, EndDate = endDate, }; query.Metrics.AddMany("ga:adClicks", "ga:adCost"); query.Dimenssions.AddMany("ga:keyword"); query.MaxResults = 500; query.Filters.AddMany("ga:campaign!~Retargeting", "ga:campaign!~Remarketing", "ga:campaign!~Display"); query.Sort = "-ga:adCost"; var keywordRows = gaService.Get<KeyWordReport>(query); var keywordFinder = new Dictionary<string, KeyWordReport>(); keywordRows.ForEach(k => { model.KeyWords.Add(k); keywordFinder.Add(k.Keyword, k); }); var searchPhrasesLeads = SearchPhrasesLeads(clientId, startDate, endDate); foreach (var searchPhraseLead in searchPhrasesLeads) { if (!string.IsNullOrEmpty(searchPhraseLead) && keywordFinder.ContainsKey(searchPhraseLead)) { keywordFinder[searchPhraseLead].NumLead = keywordFinder[searchPhraseLead].NumLead + 1; } } var searchPhrasesNotLeads = SearchPhrasesNotLeads(clientId, startDate, endDate); foreach (var searchPhraseNotLead in searchPhrasesNotLeads) { if (!string.IsNullOrEmpty(searchPhraseNotLead) && keywordFinder.ContainsKey(searchPhraseNotLead)) { keywordFinder[searchPhraseNotLead].NumNotALead = keywordFinder[searchPhraseNotLead].NumNotALead + 1; } } var searchPhrasesContacts = SearchPhrasesContacts(clientId, startDate, endDate); foreach (var searchPhraseContact in searchPhrasesContacts) { if (!string.IsNullOrEmpty(searchPhraseContact) && keywordFinder.ContainsKey(searchPhraseContact)) { keywordFinder[searchPhraseContact].Contacts = keywordFinder[searchPhraseContact].Contacts + 1; } } return View(model); }
private async Task _newClient(BookingViewModel bookingVM) { try { LinkedListNode<INavigableViewModel> prevNode = _navigation.Find(bookingVM); ClientViewModel clientVM = new ClientViewModel(_navigation, _clientEntity, prevNode); await _roomChoices.AssignRoomsCommand.ExecuteAsync(_booking); bool success = _checkRoomCapacityWithBabies(bookingVM); if (success) { NextCalled?.Invoke(null, bookingVM); } } catch (Exception ex) { Logger.Log(ex); } }
public ActionResult Register(FormCollection fc) { ViewBag.CountryList = new SelectList(CountryHelper.GetCountries(), "CountryCode", "CountryName"); ViewBag.RepresentedCountry = new SelectList(CountryHelper.GetRepresentedCountries(), "CountryCode", "CountryName"); ViewBag.NationalityList = new SelectList(NationalityHelper.GetCountries(), "Nationality", "Nationality"); ViewBag.Services = new SelectList(ServiceHelper.GetItems(), "ServiceType", "ServiceType"); ViewBag.Status = new SelectList(StatusTypeHelper.GetStatus(), "StatusType", "StatusType"); ViewBag.CourseLevel = new SelectList(CourseLevelHelper.GetItems(), "CourseLevel", "CourseLevel"); IEnumerable<Branch> branch = db.Branches.ToList(); ViewBag.Branch = branch; ClientViewModel model = new ClientViewModel(); // Manually adding data into the model (sadly) model.ClientModel = new Client(); model.ClientModel.Title = fc["ClientModel.Title"]; model.ClientModel.GivenName = fc["ClientModel.GivenName"]; model.ClientModel.LastName = fc["ClientModel.LastName"]; model.ClientModel.Dob = DateTime.ParseExact(fc["ClientModel.Dob"], "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); model.ClientModel.Nationality = fc["ClientModel.Nationality"]; model.ClientModel.Email = fc["ClientModel.Email"]; model.ClientModel.ContactNumber = fc["ClientModel.ContactNumber"]; model.ClientModel.SecondaryContactNumber = fc["ClientModel.SecondaryContactNumber"]; model.ClientModel.Address = new Address(); model.ClientModel.Address.Address_Name = fc["AddressModel.Address_Name"]; model.ClientModel.Address.State = fc["AddressModel.State"]; model.ClientModel.Address.City = fc["AddressModel.City"]; model.ClientModel.Address.Country_Id = Convert.ToInt32(fc["AddressModel.Country_Id"]); model.ClientModel.Address.Zipcode = Convert.ToInt32(fc["AddressModel.Zipcode"]); model.ClientModel.PreferredCountry = fc["ClientModel.PreferredCountry"]; model.ClientModel.Services = fc["ClientModel.Services"]; model.ClientModel.Registered_On = DateTime.Now; model.ClientModel.Branch_Id = Convert.ToInt32(fc["selectedBranch"]); // Associate ID (Optional) if (Convert.ToInt32(fc["ClientModel.Associate_Id"]) <= 0) model.ClientModel.Associate_Id = null; else model.ClientModel.Associate_Id = Convert.ToInt32(fc["ClientModel.Associate_Id"]); // Partial registration (user choose to book an appointment for enquiry if (!(fc["isFullRegistration"] == "yes")) { try { //if (ModelState.IsValid) //if (TryValidateModel(model.ClientModel)) //{ ValidateModel(model.ClientModel); db.Clients.AddObject(model.ClientModel); db.SaveChanges(); return RedirectToAction("RequestAppointment", "Client", new { id = model.ClientModel.Client_Id }); //} } catch (Exception e) { Debug.WriteLine("{0} First exception caught.", e); Debug.WriteLine(e.InnerException); ModelState.AddModelError("", e); } } // If Full Registration else { try { //if (ModelState.IsValid) if (TryValidateModel(model.ClientModel)) { // Attempt to register the user string username = fc["Username"]; string password = fc["Password"]; MembershipCreateStatus createStatus; Membership.CreateUser(username, password, model.ClientModel.Email, null, null, true, null, out createStatus); Roles.AddUserToRole(fc["Username"], "Student"); if (createStatus == MembershipCreateStatus.Success) { //FormsAuthentication.SetAuthCookie(fc["Username"], false /* createPersistentCookie */); // Create new student entry in Database Student student = new Student(); student.Client_Id = model.ClientModel.Client_Id; student.UserName = username; model.ClientModel.Students.Add(student); db.Clients.AddObject(model.ClientModel); db.SaveChanges(); Case nCase = AddNewCase(model.ClientModel.Branch_Id, student); AddDocumentTemplate(nCase); db.SaveChanges(); LogHelper.writeToSystemLog(new string[] { CookieHelper.Username }, (CookieHelper.Username + " Registered a new client " + model.ClientModel.GivenName + " " + model.ClientModel.LastName), LogHelper.LOG_OTHER, LogHelper.SECTION_CLIENT); return RedirectToAction("LogOn", "Account", new { message = "registration-success" }); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } } catch (Exception e) { Debug.WriteLine("{0} First exception caught.", e); Debug.WriteLine(e.InnerException); ModelState.AddModelError("", e); } } return View(model); }
public ActionResult Register(int id = -1) { FillRegistrationViewBagComponent(); if (id <= -1) { ViewBag.RegisterType = "full"; return View(new ClientViewModel()); } else { ViewBag.RegisterType = "continue"; Client c = db.Clients.SingleOrDefault(x => x.Client_Id == id); ClientViewModel cViewModel = new ClientViewModel(); cViewModel.ClientModel = c; return View("RegisterContinue", cViewModel); } }
public IActionResult Update(ClientViewModel model) { _clientRepository.Update(model.Client); return(RedirectToAction("Index")); }
private void EditClient_Click(object sender, RoutedEventArgs e) { if (!InValidContext()) { return; } var clientViewModel = new ClientViewModel() { Id = int.Parse(Id.Text), Name = Name.Text, MiddleName = MiddleName.Text, LastName = LastName.Text, SecondSurName = SecondSurName.Text, Age = int.Parse(Age.Text), Address = Address.Text, Identification = Identification.Text, IdentityGuid = IdentityGuid.Text, Phone = Phone.Text }; try { _clientRepository.UpateClient(clientViewModel.Id, clientViewModel); var rutaBorrar = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\KallpaBox\\TempAssets"; var rutaDesktop = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\KallpaBox\\Assets"; var photo = _photoRepository.GetPhotoClientId(_idClient); var rutaTemp = rutaBorrar + "\\" + _idClient + ".jpg"; if (ImageClient.Source != null) { if (!(Directory.Exists(rutaDesktop))) { Directory.CreateDirectory(rutaDesktop); } if (!(Directory.Exists(rutaBorrar))) { Directory.CreateDirectory(rutaBorrar); } var imagetemp = ImageClient.Source as BitmapSource; ImageClient.Source = null; ImageClient.UpdateLayout(); File.Delete(photo.PhotoClient); Thread.Sleep(1000); if (photo != null) { photo.PhotoClient = rutaDesktop + "\\" + _idClient + ".jpg"; _photoRepository.UpdatePhoto(photo); } else { photo = new Photo() { ClientId = _idClient, PhotoClient = rutaDesktop + "\\" + _idClient + ".jpg", LengthPhoto = FileInfoExtension.ObtenerTamanoArchivo(photo.PhotoClient) }; _photoRepository.CreatePhoto(photo); } BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(imagetemp)); FileIOPermission f = new FileIOPermission(FileIOPermissionAccess.Write, rutaDesktop); f.AllLocalFiles = FileIOPermissionAccess.Write; try { f.Demand(); } catch (SecurityException s) { Console.WriteLine(s.Message); } using (var fileStream = new FileStream(photo.PhotoClient, FileMode.Create)) { encoder.Save(fileStream); } } CleanControls(); PresentationMessage.ShowMessegeQueue(this.SnackBarEditClients.MessageQueue, "Cliente editado con exito"); } catch (Exception ex) { throw new Exception($"Error {ex.Message}", ex); } }
public ClientViewModel UpdateClient(ClientViewModel client) { var clientFromDb = this.Data.Clients.All() .FirstOrDefault(p => p.Id == client.Id); clientFromDb.Name = client.Name; clientFromDb.NameBulgarian = client.NameBulgarian; clientFromDb.TypeOfCompany = client.TypeOfCompany; clientFromDb.Uic = client.Uic; clientFromDb.Vat = client.Vat; clientFromDb.ResidenceAndAddress = client.ResidenceAndAddress; clientFromDb.ResidenceAndAddressInBulgarian = client.ResidenceAndAddressInBulgarian; clientFromDb.Region = client.Region; clientFromDb.NetworkPage = client.NetworkPage; clientFromDb.ContactPerson = client.ContactPerson; clientFromDb.PhoneNumber = client.PhoneNumber; clientFromDb.Email = client.Email; clientFromDb.Correspondence = client.Correspondence; clientFromDb.FixedPhoneService = client.FixedPhoneService; clientFromDb.MobileVoiceServicesProvidedThroughNetwork = client.MobileVoiceServicesProvidedThroughNetwork; clientFromDb.InternetSubs = client.InternetSubs; clientFromDb.ServicesMobileAccessToInternet = client.ServicesMobileAccessToInternet; clientFromDb.TvSubs = client.TvSubs; clientFromDb.Coverage = client.Coverage; clientFromDb.PostCode = client.PostCode; clientFromDb.Management = client.Management; clientFromDb.ManagementInBulgarian = client.ManagementInBulgarian; clientFromDb.ManagementPhone = client.ManagementPhone; clientFromDb.ManagementEmail = client.ManagementEmail; clientFromDb.Finance = client.Finance; clientFromDb.FinancePhone = client.FinancePhone; clientFromDb.FinanceAddress = client.FinanceAddress; clientFromDb.FinanceEmail = client.FinanceEmail; clientFromDb.TechnicalName = client.TechnicalName; clientFromDb.TechnicalPhone = client.TechnicalPhone; clientFromDb.TechnicalEmail = client.TechnicalEmail; clientFromDb.Marketing = client.Marketing; clientFromDb.MarketingPhone = client.MarketingPhone; clientFromDb.MarketingEmail = client.MarketingEmail; //clientFromDb.DealerName = client.DealerName; //clientFromDb.DealerEmail = client.DealerEmail; //clientFromDb.DealerPhone = client.DealerPhone; clientFromDb.WantToReceiveNews = client.WantToReceiveNews; clientFromDb.WantToReceiveEpg = client.WantToReceiveEpg; clientFromDb.IsVisible = client.IsVisible; this.Data.Clients.SaveChanges(); return client; }
public List <ContactViewModel> validateDataContact(List <string> lsData, string separator) { String sline = "--------------------------------------------------------------------------"; var lsContacts = new List <ContactViewModel>(); int cont = 0; ClientViewModel clientByContact = new ClientViewModel(); JobTitleViewModel jobTitle = new JobTitleViewModel(); BranchViewModel branchByContact = new BranchViewModel(); string sDocumentByClient = ""; string sNameByContact = ""; string sJobTitle = ""; string sPhone = ""; string sCellPhone = ""; string sAdress = ""; string sEmail = ""; try { using (BDRAEntities db = new BDRAEntities()) { foreach (var data in lsData) { cont += 1; if (cont == 1) { continue; } Console.WriteLine(sline); Console.WriteLine("Validanto linea: " + cont); Console.WriteLine(data); var aData = data.Split(separator); sDocumentByClient = aData[(int)atrContact.clientDocument].ToString(); clientByContact = db.Client.Where(cl => cl.cli_document == sDocumentByClient) .Select(cl => new ClientViewModel { id = cl.cli_document, name = cl.cli_name }) .FirstOrDefault(); if (clientByContact != null) { Console.WriteLine("Cliente: " + clientByContact.name); sNameByContact = aData[(int)atrContact.name].ToString(); Console.WriteLine("Contacto: " + sNameByContact); var name = ""; var lastName = ""; var aName = sNameByContact.Split(" "); for (int i = 0; i < aName.Length; i++) { if (aName.Length == 2) { if (i == 0) { name = aName[i]; } else { lastName = aName[i]; } } else { if (i <= 1) { name += aName[i] + " "; } else { lastName += aName[i] + " "; } } } Console.WriteLine("Nombre del contacto: " + name); if (name.Trim() == "") { Console.WriteLine("Contacto no valido ............."); continue; } Console.WriteLine("Apellido del contacto: " + lastName); sJobTitle = aData[(int)atrContact.jobTitle].ToString().ToUpper().Trim(); sJobTitle = sJobTitle.Replace(" ", " "); Console.WriteLine("Cargo: " + sJobTitle); jobTitle = db.JobTitlesClient.Where(jt => jt.jtcl_description.ToUpper() == sJobTitle) .Select(jt => new JobTitleViewModel { id = jt.jtcl_id, description = jt.jtcl_description }) .FirstOrDefault(); if (jobTitle == null) { JobTitlesClient jt = new JobTitlesClient(); jt.jtcl_description = sJobTitle; jt.jtcl_state = true; db.JobTitlesClient.Add(jt); db.SaveChanges(); Console.WriteLine("Se crea cargo en la bd..."); jobTitle = db.JobTitlesClient.Where(jt => jt.jtcl_description.ToUpper() == sJobTitle) .Select(jt => new JobTitleViewModel { id = jt.jtcl_id, description = jt.jtcl_description }) .FirstOrDefault(); } sPhone = aData[(int)atrContact.phone].ToString().Trim(); Console.WriteLine("Teléfono: " + sPhone); sCellPhone = aData[(int)atrContact.cellphone].ToString().Trim(); Console.WriteLine("Celular: " + sCellPhone); sAdress = aData[(int)atrContact.adress].ToString().Trim(); Console.WriteLine("Dirección: " + sAdress); sEmail = aData[(int)atrContact.email].ToString().Trim(); Console.WriteLine("Email: " + sEmail); branchByContact = db.branch.Where(b => b.cli_document == clientByContact.id && b.bra_isMain == true) .Select(b => new BranchViewModel { id = b.bra_id, name = b.bra_name }) .FirstOrDefault(); if (branchByContact == null) { branch branchCnt = new branch(); branchCnt.bra_isMain = true; branchCnt.bra_state = true; branchCnt.bra_name = "PRINCIPAL " + clientByContact.name; branchCnt.cli_document = clientByContact.id; db.branch.Add(branchCnt); db.SaveChanges(); branchByContact = db.branch.Where(b => b.cli_document == clientByContact.id && b.bra_isMain == true) .Select(b => new BranchViewModel { id = b.bra_id, name = b.bra_name }) .FirstOrDefault(); } Console.WriteLine("Sucursal id: " + branchByContact.id + " - " + branchByContact.name); ContactViewModel cnt = new ContactViewModel(); cnt.branch = branchByContact; cnt.name = name; cnt.lastName = lastName; cnt.phone = sPhone; cnt.cellPhone = sCellPhone; cnt.adress = sAdress; cnt.email = sEmail; cnt.jobTitle = jobTitle; lsContacts.Add(cnt); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(lsContacts); }
protected override async Task OnInitializedAsync() { Record = await Service.GetEmpty(); }
public RoomTaskEditWnd(ClientViewModel clientViewModel) { InitializeComponent(); ClientViewModel = clientViewModel; }
private void _addClient(object ignore) { try { Logger.Log("=Ajout d'un nouveau client="); Client newClient = new Client(); ClientEntity newClientEntity = new ClientEntity(newClient); Logger.Log("Ajout d'un nouveau client: Affichage de la fiche client"); ClientViewModel clientVM = new ClientViewModel(_navigation, newClientEntity); _currentEntities.Add(clientVM); _currentEntitiesView.MoveCurrentToLast(); } catch (Exception ex) { Logger.Log(ex); } }
public JsonResult DestroyClient([DataSourceRequest] DataSourceRequest request, ClientViewModel client) { var deletedClient = clients.DestroyClient(client); var loggedUserId = User.Identity.GetUserId(); Base.CreateActivity(ActivityType.Delete, deletedClient.Id.ToString(), ActivityTargetType.Client, loggedUserId); return Json(new[] { deletedClient }, JsonRequestBehavior.AllowGet); }
private void _searchClient_clientSelected(object sender, ClientEntity selectedClientEntity) { try { Logger.Log("=Recherche de client="); Logger.Log("Recherche de client: client sélectionné"); (sender as SearchClientsViewModel).ClientSelected -= _searchClient_clientSelected; Logger.Log("Recherche de client: Affichage des infos client"); ClientViewModel clientVM = new ClientViewModel(_navigation, selectedClientEntity); _currentEntities.Add(clientVM); _currentEntitiesView.MoveCurrentToLast(); } catch (Exception ex) { Logger.Log(ex); } }
/// <summary> /// Construtor para receber a ViewModel de Cliente /// </summary> /// <param name="vmCliente">VMCliente que foi chamado</param> public ClientRepository(ClientViewModel vmCliente) { _vmCliente = vmCliente; }
public ClientViewModel DestroyClient(ClientViewModel client) { var clientIdToInt = int.Parse(client.Id.ToString()); this.Data.Clients.Delete(clientIdToInt); this.Data.Clients.SaveChanges(); return client; }
public void AddClient(ClientViewModel client) { Clients.Add(client); }
public ClientViewModel CreateClient(ClientViewModel client) { var dealer = this.Data.Users .GetById(client.Dealer); var newClient = new Client { Name = client.Name, NameBulgarian = client.NameBulgarian, TypeOfCompany = client.TypeOfCompany, Uic = client.Uic, Vat = client.Vat, ResidenceAndAddress = client.ResidenceAndAddress, ResidenceAndAddressInBulgarian = client.ResidenceAndAddressInBulgarian, Region = client.Region, NetworkPage = client.NetworkPage, ContactPerson = client.ContactPerson, PhoneNumber = client.PhoneNumber, Email = client.Email, Correspondence = client.Correspondence, FixedPhoneService = client.FixedPhoneService, MobileVoiceServicesProvidedThroughNetwork = client.MobileVoiceServicesProvidedThroughNetwork, InternetSubs = client.InternetSubs, ServicesMobileAccessToInternet = client.ServicesMobileAccessToInternet, TvSubs = client.TvSubs, Coverage = client.Coverage, PostCode = client.PostCode, DealerId = client.Dealer, Dealer = dealer, Management = client.Management, ManagementInBulgarian = client.ManagementInBulgarian, ManagementPhone = client.ManagementPhone, ManagementEmail = client.ManagementEmail, Finance = client.Finance, FinancePhone = client.FinancePhone, FinanceAddress = client.FinanceAddress, FinanceEmail = client.FinanceEmail, TechnicalName = client.TechnicalName, TechnicalPhone = client.TechnicalPhone, TechnicalEmail = client.TechnicalEmail, Marketing = client.Marketing, MarketingPhone = client.MarketingPhone, MarketingEmail = client.MarketingEmail, Contracts = new List<ClientContract>(), Discussions = new List<Discussion>(), //DealerPhone = client.DealerPhone, //DealerEmail = client.DealerEmail, //DealerName = client.DealerName, WantToReceiveEpg = client.WantToReceiveEpg, WantToReceiveNews = client.WantToReceiveNews, IsVisible = client.IsVisible }; var marketingOperator = new Operator() { Name = client.Marketing, PhoneNumber = client.MarketingPhone, Email = client.MarketingEmail }; this.Data.Operators.Add(marketingOperator); this.Data.Clients.Add(newClient); this.Data.SaveChanges(); client.Id = newClient.Id; return client; }
public bool IsAccepted(ClientViewModel clientViewModel) { if (ClientId != null) { return(clientViewModel.Id == ClientId.Value); } if (IsOnline != null && clientViewModel.IsOnline != IsOnline.Value) { return(false); } if (IsAdministrator != null && clientViewModel.IsAdministrator != IsAdministrator.Value) { return(false); } if (OsName != null && clientViewModel.OsName.IndexOf(OsName, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } if (Username != null && clientViewModel.UserName.IndexOf(Username, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } if (Compatible != null && clientViewModel.ApiVersion == App.ClientApiVersion != Compatible.Value) { return(false); } if (Group != null && clientViewModel.Group.IndexOf(Group, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } if (Language != null) { var languageElements = clientViewModel.Language.Split('-'); if (!Language.StartsWith(languageElements[0], StringComparison.OrdinalIgnoreCase) && !(languageElements.Length > 1 && Language.StartsWith(languageElements[1], StringComparison.OrdinalIgnoreCase)) && clientViewModel.LanguageName.IndexOf(Language, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } } if (Country != null) { if (!string.Equals(clientViewModel.GeoLocationTwoLetter, Country, StringComparison.OrdinalIgnoreCase) && !clientViewModel.GeoLocationCountry.StartsWith(Country, StringComparison.OrdinalIgnoreCase)) { return(false); } } if (!string.IsNullOrEmpty(SearchText)) { if (clientViewModel.UserName.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) == -1 && clientViewModel.Id.ToString() != SearchText && clientViewModel.OsName.IndexOf(SearchText, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } } return(true); }