/// <summary> /// Starting point of plugin execution. /// </summary> /// <param name="pluginContext"> Used for accesssing service and the target object </param> protected override void Execute(IPluginContext pluginContext) { Entities.Contact target; try { target = pluginContext.Target.ToEntity <Entities.Contact>(); } catch { return; } if (pluginContext.EventType == CrmEventType.Create) { // Functions that perform perticular task. } else if (pluginContext.EventType == CrmEventType.Delete) { Entities.Contact postImage = pluginContext.PostImage.ToEntity <Entities.Contact>(); // function that perform perticular tasks. } else if (pluginContext.EventType == CrmEventType.Update) { Entities.Contact preImage = pluginContext.Preimage.ToEntity <Entities.Contact>(); // function that perform perticular tasks. } }
public static Entities.Contact Map(FileUploadContact fileContact, Entities.Contact contact, Guid employerGuid) { if (contact == null) { contact = new Entities.Contact(); contact.Id = Guid.NewGuid(); } contact.EntityRefId = employerGuid; var contactType = GetContactType(fileContact.ContactType); var preferredMethodOfContact = GetPreferredMethodOfContact(fileContact.PreferredContact); contact.ContactTypeId = (int)contactType; contact.PreferredContactMethodType = (int)preferredMethodOfContact; //contact.IsPrimary contact.FirstName = fileContact.FirstName; contact.MiddleName = fileContact.MiddleName; contact.LastName = fileContact.LastName; contact.JobTitle = fileContact.JobTitle; contact.BusinessPhone = fileContact.PhoneBusiness; contact.MobilePhone = fileContact.PhoneMobile; contact.HomePhone = fileContact.PhoneHome; //contact.Email = fileContact.Email; contact.CreatedOn = fileContact.Created; contact.ModifiedOn = fileContact.ModifiedOn; return(contact); }
public ContactMustBeUniqueRule( IContactsContext contactsContext, Entities.Contact contact) { _contactsContext = contactsContext; _contact = contact; }
internal bool Delete(Entities.Contact contact) { bool res = false; try { this.query.Parameters.Clear(); this.query.Parameters.Add(new SqlParameter("@ContactId", contact.Id)); int affected; res = this.query.ExecuteUpdateProc("PersonContactDeleteById", out affected); } catch (Exception ex) { try { DomainModel.Application.Status.Update( StatusController.Abstract.StatusTypes.Error, "", ex.Message); } catch { } } return(res); }
public void Post_UpdateContact([FromBody] Models.Contact mContact) { IContactBS bs = DIFactoryDesigntime.GetInstance <IContactBS>(); IBaseConverter <Models.Contact, Entities.Contact> convtResult = new AutoMapConverter <Models.Contact, Entities.Contact>(); Entities.Contact eContact = convtResult.ConvertObject(mContact); bs.UpdateContact(eContact); }
public void onInfoResponse(InfoMessage info) { ContactlistRootobjectResponse contactlistRootobjectResponse = MySendRequestHelper.Instance.getServerContactListRootObject(info.Content.StringBuffer); ContactService contactService = ContactService.Instance; foreach (var c in contactlistRootobjectResponse.ContactListResponse.contactsPresence) { Entities.Contact myContact = new Entities.Contact(c.contact.userName, c.contact.displayName, c.contact.aliases[0].completeAliasName, ContactType.Aeonix); contactService.updateContact(myContact); } }
private void OnContactBindingSourceCurrentItemChanged(object sender, System.EventArgs e) { _currentContact = uxContactBindingSource.Current as Entities.Contact; if (_currentContact != null) { _currentContact.Validate(); } //_Contact.Validate(); OnCurrentEntityChanged(); }
public void TestCreated() { _contact = new Entities.Contact() { Info = new ValueObjects.Info { Address = "Cr 25 # 7B Bis", Names = "Carlos Andrés Catilla García", Phone = "+573043541475" }, }; Console.WriteLine(_contact.Info); }
protected void MapContactToObject(SqlDataReader reader, object userData) { Entities.Contact contact = new Entities.Contact(); contact.Id = Utils.GetSafeInt32(reader, "ContactId"); contact.Media = DomainModel.ContactMediaTypes.GetById( Utils.GetSafeInt32(reader, "ContactMediaId")); contact.Value = Utils.GetSafeString(reader, "ContactValue"); contact.IsDirty = false; Entities.TourMember member = (Entities.TourMember)userData; member.Contacts.Add(contact); }
public void ExecuteTest() { using (var ctx = Kipon.Xrm.Fake.Repository.PluginExecutionFakeContext.ForType <Kipon.Solid.Plugin.Plugins.Contact.ContactDeletePlugin>()) { var contact = new Entities.Contact { ContactId = Kipon.Solid.Plugin.Plugins.Contact.ContactDeletePlugin.TESTID }; contact["fullname"] = "solid test"; ctx.AddEntity(contact); ctx.Delete(new Microsoft.Xrm.Sdk.EntityReference(Entities.Contact.EntityLogicalName, contact.ContactId.Value)); } }
protected Object ContactMediaImageGetter(Object rowObject) { Entities.Contact contact = (Entities.Contact)rowObject; if (contact != null) { if (this.mediaImages.ContainsKey(contact.Media.Id)) { return(DomainModel.Application.ResourceManager.GetImage(this.mediaImages[contact.Media.Id])); } } return(null); }
public Contact Map(Entities.Contact dbContact) { if (dbContact == null) { return(null); } return(new Contact( Guid.Parse(dbContact.Id), dbContact.Name, dbContact.Telephone, dbContact.Email, dbContact.Address)); }
public AddContactResponse Post_AddContact([FromBody] Models.Contact mContact) { IContactBS bs = DIFactoryDesigntime.GetInstance <IContactBS>(); IBaseConverter <Models.Contact, Entities.Contact> convtResult = new AutoMapConverter <Models.Contact, Entities.Contact>(); Entities.Contact eContact = convtResult.ConvertObject(mContact); bs.AddContact(eContact); var addContactResponse = new AddContactResponse() { ContactID = eContact.ContactID }; return(addContactResponse); }
private string GetContactValue(Entities.ContactCollection contacts, eContactType type) { string contactValue = String.Empty; if (contacts != null) { Entities.Contact tempContact = contacts.GetForContactType(type); if (tempContact != null) { contactValue = tempContact.ContactDetail; } } return(contactValue); }
public async Task Execute(Entities.Contact contact) { _fileUploadContext.Contact.Add(contact); int createdRecordCount; try { createdRecordCount = await _fileUploadContext.SaveAsync(); } catch (DbUpdateException due) { // Log throw; } }
public async Task Execute(Entities.Contact contact) { _fileUploadContext.Contact.Update(contact).State = EntityState.Modified; int updatedRecordCount; try { updatedRecordCount = await _fileUploadContext.SaveAsync(); } catch (DbUpdateException due) { // Log throw; } }
public void TwoInnerJoinEntityQueryTest() { using (var ctx = PluginExecutionFakeContext.ForType <Kipon.Solid.Plugin.Plugins.Account.AccountCreatePlugin>()) { var a1 = new Entities.Account { AccountId = Guid.NewGuid(), Name = "Kurt A/S" }; var a2 = new Entities.Account { AccountId = Guid.NewGuid(), Name = "Lars ApS" }; var c1 = new Entities.Contact { ContactId = Guid.NewGuid(), FirstName = "Kurt", LastName = "Jensen", ParentCustomerId = new Microsoft.Xrm.Sdk.EntityReference(Entities.Account.EntityLogicalName, a1.AccountId.Value) }; var c2 = new Entities.Contact { ContactId = Guid.NewGuid(), FirstName = "Kurt", LastName = "Vilhjem", ParentCustomerId = new Microsoft.Xrm.Sdk.EntityReference(Entities.Account.EntityLogicalName, a1.AccountId.Value) }; var c3 = new Entities.Contact { ContactId = Guid.NewGuid(), FirstName = "Lars", LastName = "Madsen", ParentCustomerId = new Microsoft.Xrm.Sdk.EntityReference(Entities.Account.EntityLogicalName, a2.AccountId.Value) }; ctx.AddEntity(a1); ctx.AddEntity(a2); ctx.AddEntity(c1); ctx.AddEntity(c2); ctx.AddEntity(c3); var accountQuery = ctx.GetQuery <Entities.Account>(); var contactQuery = ctx.GetQuery <Entities.Contact>(); var kurt = (from a in accountQuery join c in contactQuery on a.AccountId equals c.ParentCustomerId.Id where a.Name == "Kurt A/S" select new { Name = a.Name, Firstname = c.FirstName, Lastname = c.LastName }).ToArray().OrderBy(r => r.Lastname).ToArray(); Assert.AreEqual(2, kurt.Length); Assert.AreEqual("Kurt A/S", kurt.First().Name); Assert.AreEqual("Jensen", kurt.First().Lastname); Assert.AreEqual("Vilhjem", kurt.Last().Lastname); } }
public void CreateOrUpdateContact(Entities.Contact contact) { string sqlAdd = "INSERT INTO Contact (firstName, surname, phone, email, street, city, postalCode, picturePath, userId) VALUES (@Firstname, @Surname, @Phone, @Email, @Street, @City, @Postalcode, @PicturePath, @UserId)"; string sqlUpdate = "UPDATE Contact SET firstName = @Firstname, surname = @Surname, phone = @Phone, email = @Email, street = @Street, city = @City, postalCode = @Postalcode, picturePath = @PicturePath WHERE id = @Id"; using (var conn = GetSQLiteConnection()) { if (contact.Id == 0) { conn.Execute(sqlAdd, contact); } else { conn.Execute(sqlUpdate, contact); } } }
public AddContactsResponse Post_AddContacts([FromBody] List <Models.Contact> mContactList) { var contactIdList = new List <int>(); IContactBS bs = DIFactoryDesigntime.GetInstance <IContactBS>(); foreach (var mContact in mContactList) { IBaseConverter <Models.Contact, Entities.Contact> convtResult = new AutoMapConverter <Models.Contact, Entities.Contact>(); Entities.Contact eContact = convtResult.ConvertObject(mContact); bs.AddContact(eContact); contactIdList.Add(eContact.ContactID); } var resp = new AddContactsResponse(); resp.ContactIdList = contactIdList; return(resp); }
private async Task Load(CreateContactCommand command) { this._contact = await this._contactRepository.GetByContactTypeAndEmail(command.ContactTypeID, command.EmailAddress); if (command.ClubID.HasValue) { this._club = await this._clubRepository.GetWithContacts(command.ClubID.Value); } if (command.TeamID.HasValue && command.ContactTypeID == ContactTypes.Captain) { this._team = await this._teamRepository.Get(command.TeamID.Value); } if (command.AssociationID.HasValue) { this._association = await this._associationRepository.GetWithContacts(command.AssociationID.Value); } }
public IHttpActionResult Post([FromUri] string id, [FromBody] Entities.Contact contact) { var db = new PetaPoco.Database("AGSoftware"); var a = db.SingleOrDefault <Entities.AspNetUsers>("Select * from AspNetUsers Where PhoneNumber = @0", contact.PhoneNumber); if (a != null) { Entities.ContactList contactlist = new Entities.ContactList(); contactlist.UserId = Storytime.Providers.UserHelper.GetUserId(this.User.Identity.Name); contactlist.ContactId = a.Id; contactlist.DateCreated = System.DateTime.Now; db.Insert(contactlist); return(Ok()); } else { return(NotFound()); } }
internal bool Update(Entities.TourMember member, Entities.Contact contact) { bool res = false; try { if (contact.Id < 0) { DomainModel.Application.Status.Update( StatusTypes.Warning, "stat_wrn_db_id_not_exists"); return(true); } this.query.Parameters.Clear(); this.query.Parameters.Add(new SqlParameter("@ContactMediaId", contact.Media.Id)); this.query.Parameters.Add(new SqlParameter("@ContactValue", contact.Value)); this.query.Parameters.Add(new SqlParameter("@ContactId", contact.Id)); this.query.Parameters.Add(new SqlParameter("@PersonId", member.Id)); int affected; res = this.query.ExecuteUpdateProc("PersonContactUpdateById", out affected); } catch (Exception ex) { try { DomainModel.Application.Status.Update( StatusController.Abstract.StatusTypes.Error, "", ex.Message); } catch { } } return(res); }
private DataSet GetContactDataSet(List <Entities.Individual> individualContacts, eContactType contactType) { DataSet contactsDataSet = new DataSet(); DataTable contactTable = new DataTable("contactTable"); string contactNameColumn = "ContactName"; string contactDetailColumn = "ContactDetail"; string ContactDisplayColumn = "ContactDisplay"; contactTable.Columns.Add(contactNameColumn); contactTable.Columns.Add(contactDetailColumn); contactTable.Columns.Add(ContactDisplayColumn); contactsDataSet.Tables.Add(contactTable); foreach (Entities.Individual individual in individualContacts) { if (individual.Contacts != null) { Entities.Contact contact = individual.Contacts.GetForContactType(contactType); if (contact != null) { DataRow row = contactsDataSet.Tables[0].NewRow(); row[contactNameColumn] = String.Format("{0} {1} {2}", individual.Title, individual.FirstNames, individual.LastName); row[contactDetailColumn] = contact.ContactDetail; row[ContactDisplayColumn] = String.Format("{0} - {1}", row[contactNameColumn], row[contactDetailColumn]); contactsDataSet.Tables[0].Rows.Add(row); } } } return(contactsDataSet); }
public void Initialize() { _contact = new Entities.Contact(); }
/// <summary> /// Load Driver /// </summary> private void LoadDriver() { if (ViewState["driver"] == null) { IDriver facDriver = new Facade.Resource(); _driver = facDriver.GetDriverForIdentityId(_identityId); ViewState["driver"] = _driver; } else { _driver = (Entities.Driver)ViewState["driver"]; } if (_driver != null) { hypAddNewVehicle.Visible = true; cboTitle.SelectedValue = Utilities.UnCamelCase(_driver.Individual.Title.ToString()); txtFirstNames.Text = _driver.Individual.FirstNames; txtLastName.Text = _driver.Individual.LastName; txtPasscode.Text = _driver.Passcode; dteDOB.SelectedDate = _driver.Individual.DOB; if (_driver.Individual.Contacts != null && _driver.Individual.Contacts.Count > 0) { Entities.Contact telephone = _driver.Individual.Contacts.GetForContactType(eContactType.Telephone); Entities.Contact mobile = _driver.Individual.Contacts.GetForContactType(eContactType.MobilePhone); Entities.Contact personalMobile = _driver.Individual.Contacts.GetForContactType(eContactType.PersonalMobile); if (telephone != null) { txtTelephone.Text = telephone.ContactDetail; } if (mobile != null) { txtMobilePhone.Text = mobile.ContactDetail; } if (personalMobile != null) { txtPersonalMobile.Text = personalMobile.ContactDetail; } } if (_driver.Individual.Address != null) { txtAddressLine1.Text = _driver.Individual.Address.AddressLine1; txtAddressLine2.Text = _driver.Individual.Address.AddressLine2; txtAddressLine3.Text = _driver.Individual.Address.AddressLine3; txtPostTown.Text = _driver.Individual.Address.PostTown; txtCounty.Text = _driver.Individual.Address.County; txtPostCode.Text = _driver.Individual.Address.PostCode; if (_driver.Individual.Address.TrafficArea != null) { hidTrafficArea.Value = _driver.Individual.Address.TrafficArea.TrafficAreaId.ToString(); } } foreach (Entities.Contact contact in _driver.Individual.Contacts) { if (contact.ContactType == eContactType.Telephone) { txtTelephone.Text = contact.ContactDetail; } if (contact.ContactType == eContactType.MobilePhone) { txtMobilePhone.Text = contact.ContactDetail; } if (contact.ContactType == eContactType.PersonalMobile) { txtPersonalMobile.Text = contact.ContactDetail; } } Facade.IPoint facPoint = new Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(_driver.HomePointId); if (point != null && point.PointId > 0) { cboOrganisation.Text = point.OrganisationName; cboOrganisation.SelectedValue = point.IdentityId.ToString(); m_organisationId = point.IdentityId; m_startTown = point.PostTown.TownName; m_startTownId = point.PostTown.TownId; cboPoint.Text = point.Description; cboPoint.SelectedValue = point.PointId.ToString(); m_pointId = point.PointId; } cboDriverType.Items.FindByValue(_driver.DriverType.DriverTypeID.ToString()).Selected = true; cboVehicle.ClearSelection(); if (_driver.AssignedVehicleId != 0) { ListItem vehicle = cboVehicle.Items.FindByValue(_driver.AssignedVehicleId.ToString()); if (vehicle != null) { vehicle.Selected = true; } } txtDigitalTachoCardId.Text = _driver.DigitalTachoCardId; chkAgencyDriver.Checked = _driver.IsAgencyDriver; if (_driver.Individual.IdentityStatus == eIdentityStatus.Deleted) { chkDelete.Checked = true; } if (_driver.Point != null) { txtLatitude.Text = _driver.Point.Latitude.ToString(); txtLongitude.Text = _driver.Point.Longitude.ToString(); cboTown.SelectedValue = _driver.Point.PostTown.TownId.ToString(); cboTown.Text = _driver.Point.PostTown.TownName; } Entities.ControlArea ca = null; Entities.TrafficArea ta = null; using (Facade.IResource facResource = new Facade.Resource()) facResource.GetControllerForResourceId(_driver.ResourceId, ref ca, ref ta); cboDepot.ClearSelection(); if (_driver.DepotId > 0) { cboDepot.FindItemByValue(_driver.DepotId.ToString()).Selected = true; } if (ca != null && ta != null) { cboControlArea.ClearSelection(); cboControlArea.FindItemByValue(ca.ControlAreaId.ToString()).Selected = true; cboTrafficArea.ClearSelection(); cboTrafficArea.FindItemByValue(ta.TrafficAreaId.ToString()).Selected = true; } chkDelete.Visible = true; pnlDriverDeleted.Visible = true; if (_driver.DefaultCommunicationTypeID == 0) { rblDefaultCommunicationType.Items.FindByText("None").Selected = true; } else { rblDefaultCommunicationType.Items.FindByText(((eDriverCommunicationType)_driver.DefaultCommunicationTypeID).ToString()).Selected = true; } txtPayrollNo.Text = _driver.PayrollNo; dteSD.SelectedDate = _driver.StartDate; if (telematicsOption.Visible) { cboTelematicsSolution.ClearSelection(); if (_driver.TelematicsSolution.HasValue) { cboTelematicsSolution.Items.FindByText(_driver.TelematicsSolution.ToString()).Selected = true; } } //Find all tree nodes that correspond to the org units var treeNodesToCheck = m_orgUnitTreeNodes.Where(x => _driver.OrgUnitIDs.Contains(x.OrgUnitId.Value)); foreach (var treeNode in treeNodesToCheck) { treeNode.Checked = true; } if (_driver.PlannerIdentityID != null) { cboDriverPlanner.ClearSelection(); cboDriverPlanner.FindItemByValue(_driver.PlannerIdentityID.ToString()).Selected = true; } if (_driver.AgencyId != null) { cboAgency.ClearSelection(); cboAgency.FindItemByValue(_driver.AgencyId.ToString()).Selected = true; } } btnAdd.Text = "Update"; }
public ContactModelValidationRule(Entities.Contact contact) { this._contact = contact; }
/// <summary> /// Populate Driver /// </summary> private void populateDriver() { if (ViewState["driver"] == null) { _driver = new Entities.Driver(); } else { _driver = (Entities.Driver)ViewState["driver"]; } _driver.ResourceType = eResourceType.Driver; if (_driver.Individual == null) { _driver.Individual = new Entities.Individual(); } _driver.Individual.Title = (eTitle)Enum.Parse(typeof(eTitle), cboTitle.SelectedValue.Replace(" ", "")); _driver.Individual.FirstNames = txtFirstNames.Text; _driver.Individual.LastName = txtLastName.Text; if (dteDOB.SelectedDate != null) { _driver.Individual.DOB = dteDOB.SelectedDate.Value; } else { _driver.Individual.DOB = DateTime.MinValue; } _driver.Individual.IndividualType = eIndividualType.Driver; _driver.Passcode = txtPasscode.Text; if (_driver.Individual.Address == null) { _driver.Individual.Addresses = new Entities.AddressCollection(); _driver.Individual.Addresses.Add(new Entities.Address()); } _driver.Individual.Address.AddressLine1 = txtAddressLine1.Text; _driver.Individual.Address.AddressLine2 = txtAddressLine2.Text; _driver.Individual.Address.AddressLine3 = txtAddressLine3.Text; _driver.Individual.Address.PostTown = txtPostTown.Text; _driver.Individual.Address.County = txtCounty.Text; _driver.Individual.Address.PostCode = txtPostCode.Text; if (_driver.Individual.Address.TrafficArea == null) { _driver.Individual.Address.TrafficArea = new Orchestrator.Entities.TrafficArea(); } if (hidTrafficArea.Value != "") { _driver.Individual.Address.TrafficArea.TrafficAreaId = Convert.ToInt32(hidTrafficArea.Value); } if (_driver.Individual.Contacts == null) { _driver.Individual.Contacts = new Entities.ContactCollection(); } Entities.Contact contact = _driver.Individual.Contacts.GetForContactType(eContactType.Telephone); if (null == contact) { contact = new Entities.Contact(); contact.ContactType = eContactType.Telephone; _driver.Individual.Contacts.Add(contact); } contact.ContactDetail = txtTelephone.Text; contact = _driver.Individual.Contacts.GetForContactType(eContactType.MobilePhone); if (null == contact) { contact = new Entities.Contact(); contact.ContactType = eContactType.MobilePhone; _driver.Individual.Contacts.Add(contact); } contact.ContactDetail = txtMobilePhone.Text; contact = _driver.Individual.Contacts.GetForContactType(eContactType.PersonalMobile); if (contact == null) { contact = new Entities.Contact(); contact.ContactType = eContactType.PersonalMobile; _driver.Individual.Contacts.Add(contact); } contact.ContactDetail = txtPersonalMobile.Text; // Retrieve the organisation and place it in viewstate Facade.IOrganisation facOrganisation = new Facade.Organisation(); Entities.Organisation m_organisation = facOrganisation.GetForIdentityId(Orchestrator.Globals.Configuration.IdentityId); Entities.OrganisationLocation currentOrganisationLocation = null; Entities.Point currentPoint = null; Entities.Address currentAddress = null; if (m_organisation != null && m_organisation.Locations.Count > 0) { currentOrganisationLocation = m_organisation.Locations.GetHeadOffice(); currentPoint = currentOrganisationLocation.Point; currentAddress = currentPoint.Address; } if (cboPoint.SelectedValue != "") { _driver.HomePointId = Convert.ToInt32(cboPoint.SelectedValue); } else { _driver.HomePointId = currentPoint.PointId; } if (Convert.ToInt32(cboVehicle.SelectedValue) > 0) { _driver.AssignedVehicleId = Convert.ToInt32(cboVehicle.SelectedValue); } else { _driver.AssignedVehicleId = 0; } if (chkDelete.Checked) { _driver.Individual.IdentityStatus = eIdentityStatus.Deleted; _driver.ResourceStatus = eResourceStatus.Deleted; } else { _driver.Individual.IdentityStatus = eIdentityStatus.Active; _driver.ResourceStatus = eResourceStatus.Active; } if (_driver.Point == null && cboTown.SelectedValue != "") { _driver.Point = new Entities.Point(); } if (cboDepot.SelectedValue != "") { _driver.DepotId = Convert.ToInt32(cboDepot.SelectedValue); } else { _driver.DepotId = currentOrganisationLocation.OrganisationLocationId; } if (_driver.Point != null) { decimal dLatitude = 0; decimal.TryParse(txtLatitude.Text, out dLatitude); decimal dLongtitude = 0; decimal.TryParse(txtLongitude.Text, out dLongtitude); _driver.Individual.Address.Latitude = dLatitude; _driver.Individual.Address.Longitude = dLongtitude; _driver.Point.PostTown = new Entities.PostTown(); Facade.IPostTown facPostTown = new Facade.Point(); _driver.Point.IdentityId = 0; _driver.Point.PostTown = facPostTown.GetPostTownForTownId(Convert.ToInt32(cboTown.SelectedValue)); _driver.Point.Address = _driver.Individual.Address; _driver.Point.Latitude = dLatitude; _driver.Point.Longitude = dLongtitude; _driver.Point.Description = _driver.Individual.FirstNames + " " + _driver.Individual.LastName + " - Home"; // We must try to set the radius of the point so that a new geofence // can be generated as we have just changed the point location through the address lookup. // not sure that this is neccessary for drivers though if (!String.IsNullOrEmpty(this.hdnSetPointRadius.Value)) { _driver.Point.Radius = Globals.Configuration.GPSDefaultGeofenceRadius; } } if (cboDriverType.SelectedValue != "") { _driver.DriverType.DriverTypeID = int.Parse(cboDriverType.SelectedValue); } else { _driver.DriverType.DriverTypeID = 1; } _driver.DigitalTachoCardId = txtDigitalTachoCardId.Text; _driver.IsAgencyDriver = chkAgencyDriver.Checked; if (dteSD.SelectedDate != null) { _driver.StartDate = dteSD.SelectedDate.Value; } else { _driver.StartDate = null; } _driver.PayrollNo = txtPayrollNo.Text; string selectedCommunicationType = rblDefaultCommunicationType.SelectedValue; if (selectedCommunicationType == "None") { _driver.DefaultCommunicationTypeID = 0; } else { _driver.DefaultCommunicationTypeID = (int)Enum.Parse(typeof(eDriverCommunicationType), rblDefaultCommunicationType.SelectedValue); } _driver.OrgUnitIDs = trvResourceGrouping.CheckedNodes.Select(x => Int32.Parse(x.Attributes["OrgUnitID"])).ToList(); // if the telematics option is visible use the selected solution (validation enforces a non-null selection) if (telematicsOption.Visible) { _driver.TelematicsSolution = (eTelematicsSolution?)Enum.Parse(typeof(eTelematicsSolution), cboTelematicsSolution.SelectedValue); } else { // if telematics option is not visible and we're creating, use the default if (!_isUpdate && ViewState["defaultTelematicsSolution"] != null) { _driver.TelematicsSolution = (eTelematicsSolution)ViewState["defaultTelematicsSolution"]; } //otherwise leave the telematics solution as it is } if (!string.IsNullOrEmpty(cboDriverPlanner.SelectedValue)) { _driver.PlannerIdentityID = Convert.ToInt32(cboDriverPlanner.SelectedValue); } else { _driver.PlannerIdentityID = null; //PROT-6452 - un-allocating a driver from its planner } if (chkAgencyDriver.Checked) { if (cboAgency.SelectedIndex == -1) { var agency = new Agency() { Name = cboAgency.Text }; using (var uow = DIContainer.CreateUnitOfWork()) { var agenciesRepo = DIContainer.CreateRepository <IAgencyRepository>(uow); agenciesRepo.Add(agency); uow.SaveChanges(); } _driver.AgencyId = agency.AgencyId; } else { _driver.AgencyId = int.Parse(cboAgency.SelectedItem.Value); } } else { _driver.AgencyId = null; } ViewState["driver"] = _driver; }
public void UpdateContact(Entities.Contact inputEt) { this._contactRepository.UpdateContact(inputEt); }
public int AddContact(Entities.Contact inputEt) { return(this._contactRepository.AddContact(inputEt)); }
public Contact2ProductGroups(Entities.Contact contact) { this.contact = contact; productGroups = new List<Entities.ProductGroup>(); }
public async Task <DefaultIdentityCommandResponse> Handle(CreateContactCommand command) { this._unitOfWork.Begin(); try { this._validationResult = this._validator.Validate(command); if (this._validationResult.IsValid) { await this.Load(command); if (this._contact == null) { this._contact = new Entities.Contact(); this._contact.ContactTypeID = command.ContactTypeID; } this._contact.Forename = command.Forename; this._contact.Surname = command.Surname; this._contact.EmailAddress = command.EmailAddress; this._contact.Telephone = command.Telephone; await this._contactRepository.Save(this._contact); if (command.ClubID.HasValue) { if (command.TeamID.HasValue) { if (this._team.Club.ID != this._club.ID) { throw new ArgumentOutOfRangeException("club", $"Team {this._team.Name} is not associated with club {this._club.Name}"); } } this._club.AddContact(this._contact, this._team); await this._clubRepository.Save(this._club); if (this._team != null) { await this._teamRepository.Save(this._team); } } if (command.AssociationID.HasValue) { this._association.AddContact(this._contact); await this._associationRepository.Save(this._association); } } if (this._validationResult.IsValid) { this._unitOfWork.SoftCommit(); return(DefaultIdentityCommandResponse.Create(this._validationResult, this._contact.ID)); } else { this._unitOfWork.Rollback(); return(DefaultIdentityCommandResponse.Create(this._validationResult)); } } catch (Exception exception) { this._unitOfWork.Rollback(); this._logger.LogError(exception, "Exception In Command Handler"); throw; } }