protected void btnAddRoles_Click(object sender, EventArgs e) { if (Page.IsValid) { OMMDataContext context = new OMMDataContext(); if (context.ContactRoles.FirstOrDefault(P => P.ContactID == _ContactID && P.RoleID == Convert.ToInt32(ddlRoles.SelectedValue)) == null) { ContactRole entity = null; entity = new ContactRole(); entity.ContactID = _ContactID; entity.RoleID = Convert.ToInt32(ddlRoles.SelectedValue); entity.ChangedByUserID = SessionCache.CurrentUser.ID; entity.ChangedOn = DateTime.Now; entity.RoleOrder = Convert.ToInt32(RoleOrderNo.Text); context.ContactRoles.InsertOnSubmit(entity); context.SubmitChanges(); String url = String.Format("{0}?{1}={2}&{3}=True" , Request.Url.AbsolutePath , AppConstants.QueryString.CONTACT_ID, _ContactID , AppConstants.QueryString.SUCCESS_MSG); Response.Redirect(url); } } }
public async Task <IActionResult> Edit(int id, [Bind("ID,ContactId,RoleId,WholesalerId")] ContactRole contactRole) { if (id != contactRole.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(contactRole); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactRoleExists(contactRole.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(contactRole)); }
public static int SavePersonnel(App.CustomModels.Personnel personnel, List <App.CustomModels.PersonnelTelephone> telephones, List <App.CustomModels.ConNote> ConNotes, List <App.CustomModels.PersonnelEmail> emails, List <App.CustomModels.PersonnelRole> roles) { OMMDataContext context = new OMMDataContext(); Contact contact = populateContact(personnel, context); ///Roles if (roles != null && roles.Count > 0) { foreach (App.CustomModels.PersonnelRole role in roles) { ContactRole contactRole = null; if (role.ID > 0) { contactRole = context.ContactRoles.SingleOrDefault(P => P.ID == role.ID); } else { contactRole = new ContactRole(); contact.ContactRoles.Add(contactRole); } contactRole.RoleID = role.RoleID; contactRole.RoleOrder = role.Order; contactRole.ChangedByUserID = SessionCache.CurrentUser.ID; contactRole.ChangedOn = DateTime.Now; } } context.SubmitChanges(); return(contact.ID); }
public static ContactRoleViewModel ToVM(this ContactRole e) { var entity = new ContactRoleViewModel(); entity.Id = e.Id; entity.RoleName = e.RoleName; return(entity); }
/// <summary> /// Method will upsert specified Contact Role with specified Account information. /// </summary> /// <param name="c">Contact</param> /// <param name="a">Account</param> /// <returnsNetResponsereturns> public NetResponse SaveContactRole(Contact c, Account a) { ContactRole role = new ContactRole(); Subject = RS; NetResponse NR = Subject.SaveContactRole(role); return(NR); }
public async Task <IActionResult> Create([Bind("ID,ContactId,RoleId,WholesalerId")] ContactRole contactRole) { if (ModelState.IsValid) { _context.Add(contactRole); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(contactRole)); }
/// <summary> /// Object hash code /// </summary> /// <returns></returns> public override int GetHashCode() { unchecked { var hashCode = Name != null?Name.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (ContactRole != null ? ContactRole.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AnalysisSoftware != null ? AnalysisSoftware.GetHashCode() : 0); return(hashCode); } }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 42, Configuration.FieldSeparator), Id, SetIdNk1.HasValue ? SetIdNk1.Value.ToString(culture) : null, Name != null ? string.Join(Configuration.FieldRepeatSeparator, Name.Select(x => x.ToDelimitedString())) : null, Relationship?.ToDelimitedString(), Address != null ? string.Join(Configuration.FieldRepeatSeparator, Address.Select(x => x.ToDelimitedString())) : null, PhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, PhoneNumber.Select(x => x.ToDelimitedString())) : null, BusinessPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, BusinessPhoneNumber.Select(x => x.ToDelimitedString())) : null, ContactRole?.ToDelimitedString(), StartDate.HasValue ? StartDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null, EndDate.HasValue ? EndDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null, NextOfKinAssociatedPartiesJobTitle, NextOfKinAssociatedPartiesJobCodeClass?.ToDelimitedString(), NextOfKinAssociatedPartiesEmployeeNumber?.ToDelimitedString(), OrganizationNameNk1 != null ? string.Join(Configuration.FieldRepeatSeparator, OrganizationNameNk1.Select(x => x.ToDelimitedString())) : null, MaritalStatus?.ToDelimitedString(), AdministrativeSex?.ToDelimitedString(), DateTimeOfBirth.HasValue ? DateTimeOfBirth.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, LivingDependency != null ? string.Join(Configuration.FieldRepeatSeparator, LivingDependency.Select(x => x.ToDelimitedString())) : null, AmbulatoryStatus != null ? string.Join(Configuration.FieldRepeatSeparator, AmbulatoryStatus.Select(x => x.ToDelimitedString())) : null, Citizenship != null ? string.Join(Configuration.FieldRepeatSeparator, Citizenship.Select(x => x.ToDelimitedString())) : null, PrimaryLanguage?.ToDelimitedString(), LivingArrangement?.ToDelimitedString(), PublicityCode?.ToDelimitedString(), ProtectionIndicator, StudentIndicator?.ToDelimitedString(), Religion?.ToDelimitedString(), MothersMaidenName != null ? string.Join(Configuration.FieldRepeatSeparator, MothersMaidenName.Select(x => x.ToDelimitedString())) : null, Nationality?.ToDelimitedString(), EthnicGroup != null ? string.Join(Configuration.FieldRepeatSeparator, EthnicGroup.Select(x => x.ToDelimitedString())) : null, ContactReason != null ? string.Join(Configuration.FieldRepeatSeparator, ContactReason.Select(x => x.ToDelimitedString())) : null, ContactPersonsName != null ? string.Join(Configuration.FieldRepeatSeparator, ContactPersonsName.Select(x => x.ToDelimitedString())) : null, ContactPersonsTelephoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, ContactPersonsTelephoneNumber.Select(x => x.ToDelimitedString())) : null, ContactPersonsAddress != null ? string.Join(Configuration.FieldRepeatSeparator, ContactPersonsAddress.Select(x => x.ToDelimitedString())) : null, NextOfKinAssociatedPartysIdentifiers != null ? string.Join(Configuration.FieldRepeatSeparator, NextOfKinAssociatedPartysIdentifiers.Select(x => x.ToDelimitedString())) : null, JobStatus?.ToDelimitedString(), Race != null ? string.Join(Configuration.FieldRepeatSeparator, Race.Select(x => x.ToDelimitedString())) : null, Handicap?.ToDelimitedString(), ContactPersonSocialSecurityNumber, NextOfKinBirthPlace, VipIndicator?.ToDelimitedString(), NextOfKinTelecommunicationInformation?.ToDelimitedString(), ContactPersonsTelecommunicationInformation?.ToDelimitedString() ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
/// <summary> /// Object hash code /// </summary> /// <returns></returns> public override int GetHashCode() { unchecked { var hashCode = Name != null?Name.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (Customizations != null ? Customizations.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (URI != null ? URI.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ContactRole != null ? ContactRole.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SoftwareName != null ? SoftwareName.GetHashCode() : 0); return(hashCode); } }
public NetResponse SaveContactRole(ContactRole sObject) { string objectName = "ContactRole__c"; if (string.IsNullOrEmpty(sObject.Id)) { //New record HTTPPostRequest client = new HTTPPostRequest(ObjectsURL + "" + objectName + "/", sObject.GetJSon()); return(client.Execute()); } else { //Update existing record string Id = sObject.Id; sObject.Id = null; HTTPPatchRequest client = new HTTPPatchRequest(ObjectsURL + "" + objectName + "/" + Id + "/", sObject.GetJSon()); return(client.Execute()); } }
public IActionResult Post(RelationshipType relationshipType) { var userEmail = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email).Value; var userId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value; //USER ID RETRIEVAL (FROM TOKEN) !!!!! //HOUSTON, WE GOT A PROBLEM: la tbala de usuarios esta vacia en esta API, //porque nos hemos autentificado en otra API. //var user = _db.Users.FirstOrDefault(u => u.Email == userEmail); //if (user == null) //{ // return NotFound(); //} var relationshipTypetRoleObj = new ContactRole() { Description = relationshipType.Description //UserId = user.Id, }; _db.ContactRoles.Add(relationshipTypetRoleObj); _db.SaveChanges(); return(Ok(new { vehicleId = relationshipTypetRoleObj.Id, message = "Company Relationship Added Successfully" })); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 8, Configuration.FieldSeparator), Id, ContactRole != null ? string.Join(Configuration.FieldRepeatSeparator, ContactRole.Select(x => x.ToDelimitedString())) : null, ContactName != null ? string.Join(Configuration.FieldRepeatSeparator, ContactName.Select(x => x.ToDelimitedString())) : null, ContactAddress != null ? string.Join(Configuration.FieldRepeatSeparator, ContactAddress.Select(x => x.ToDelimitedString())) : null, ContactLocation?.ToDelimitedString(), ContactCommunicationInformation != null ? string.Join(Configuration.FieldRepeatSeparator, ContactCommunicationInformation.Select(x => x.ToDelimitedString())) : null, PreferredMethodOfContact?.ToDelimitedString(), ContactIdentifiers != null ? string.Join(Configuration.FieldRepeatSeparator, ContactIdentifiers.Select(x => x.ToDelimitedString())) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
/// <summary> /// This method is used to update single Contact Role with ID and print the response. /// </summary> /// <param name="contactRoleId">The ID of the ContactRole to be updated</param> public static void UpdateContactRole(long contactRoleId) { //ID of the ContactRole to be updated //long contactRoleId = 5255085067923; //Get instance of ContactRolesOperations Class ContactRolesOperations contactRolesOperations = new ContactRolesOperations(); //Get instance of BodyWrapper Class that will contain the request body BodyWrapper bodyWrapper = new BodyWrapper(); //List of ContactRole instances List <ContactRole> contactRolesList = new List <ContactRole>(); //Get instance of ContactRole Class ContactRole cr1 = new ContactRole(); //Set name to the ContactRole instance cr1.Name = "contactRoleUpdate1"; //Set sequence number to the ContactRole instance cr1.SequenceNumber = 2; //Add ContactRole instance to the list contactRolesList.Add(cr1); //Set the list to contactRoles in BodyWrapper instance bodyWrapper.ContactRoles = contactRolesList; //Call UpdateContactRole method that takes contactRoleId and BodyWrapper instance as parameters APIResponse <ActionHandler> response = contactRolesOperations.UpdateContactRole(contactRoleId, bodyWrapper); if (response != null) { //Get the status code from response Console.WriteLine("Status Code: " + response.StatusCode); //Check if expected response is received if (response.IsExpected) { //Get object from response ActionHandler actionHandler = response.Object; if (actionHandler is ActionWrapper) { //Get the received ActionWrapper instance ActionWrapper actionWrapper = (ActionWrapper)actionHandler; //Get the list of obtained ActionResponse instances List <ActionResponse> actionResponses = actionWrapper.ContactRoles; foreach (ActionResponse actionResponse in actionResponses) { //Check if the request is successful if (actionResponse is SuccessResponse) { //Get the received SuccessResponse instance SuccessResponse successResponse = (SuccessResponse)actionResponse; //Get the Status Console.WriteLine("Status: " + successResponse.Status.Value); //Get the Code Console.WriteLine("Code: " + successResponse.Code.Value); Console.WriteLine("Details: "); //Get the details map foreach (KeyValuePair <string, object> entry in successResponse.Details) { //Get each value in the map Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value)); } //Get the Message Console.WriteLine("Message: " + successResponse.Message.Value); } //Check if the request returned an exception else if (actionResponse is APIException) { //Get the received APIException instance APIException exception = (APIException)actionResponse; //Get the Status Console.WriteLine("Status: " + exception.Status.Value); //Get the Code Console.WriteLine("Code: " + exception.Code.Value); Console.WriteLine("Details: "); //Get the details map foreach (KeyValuePair <string, object> entry in exception.Details) { //Get each value in the map Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value)); } //Get the Message Console.WriteLine("Message: " + exception.Message.Value); } } } //Check if the request returned an exception else if (actionHandler is APIException) { //Get the received APIException instance APIException exception = (APIException)actionHandler; //Get the Status Console.WriteLine("Status: " + exception.Status.Value); //Get the Code Console.WriteLine("Code: " + exception.Code.Value); Console.WriteLine("Details: "); //Get the details map foreach (KeyValuePair <string, object> entry in exception.Details) { //Get each value in the map Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value)); } //Get the Message Console.WriteLine("Message: " + exception.Message.Value); } } else { //If response is not as expected //Get model object from response Model responseObject = response.Model; //Get the response object's class Type type = responseObject.GetType(); //Get all declared fields of the response class Console.WriteLine("Type is: {0}", type.Name); PropertyInfo[] props = type.GetProperties(); Console.WriteLine("Properties (N = {0}):", props.Length); foreach (var prop in props) { if (prop.GetIndexParameters().Length == 0) { Console.WriteLine("{0} ({1}) in {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject)); } else { Console.WriteLine("{0} ({1}) in <Indexed>", prop.Name, prop.PropertyType.Name); } } } } }
public NetResponse SaveContactRole(ContactRole role) { throw new NotImplementedException(); }