private void aftabTest() { MyFileIt.MyFileItAppServiceClient obj = new MyFileIt.MyFileItAppServiceClient(); MyFileIt.MyFileItResult result = new MyFileIt.MyFileItResult(); var message = ""; int appUserIDLookup = 3; int newOrganizationID = 12; int oldOrganizationID = 10; DateTime startDate = DateTime.Now; DateTime expiresDate = DateTime.Now.AddDays(10); int yearCode = 2015; int sportTypeID = 2; int appUserTypeId = 5; AppUserDTO user = null; result = obj.GetAppUsers(appGlobal.username, appGlobal.password, appUserIDLookup, null); user = result.AppUsers.First(); user.Organizations.Where(o => o.ID == oldOrganizationID || o.ID == newOrganizationID).ToList().ForEach(o => { obj.RemoveAppUserFromOrganization(appGlobal.username, appGlobal.password, user.ID, o.ID); }); // add the new organization link into the table result = obj.AssociateAppUserToOrganization(appGlobal.username, appGlobal.password, user.ID, appUserTypeId, newOrganizationID, startDate, expiresDate, yearCode, sportTypeID); message = result.Success ? "Worked" : "Failed"; }
protected void btnShareKeyUpdate_Click(object sender, EventArgs e) { MyFileIt.MyFileItAppServiceClient obj = new MyFileIt.MyFileItAppServiceClient(); MyFileIt.MyFileItResult result = new MyFileIt.MyFileItResult(); FileCabinetDocumentDTO objf = new FileCabinetDocumentDTO(); ShareKeyDTO objKey = new ShareKeyDTO(); AppUserDTO user = new AppUserDTO(); List <AppUserDTO> objUsers = new List <AppUserDTO>(); result = obj.GetAppUsers(appGlobal.username, appGlobal.password, 2, ""); user = result.AppUsers.First(); user.SHAREKEYEXPIREDATE = DateTime.Now.AddDays(365); result = obj.UpdateAppUser(appGlobal.username, appGlobal.password, user); objKey.ID = 10; objKey.APPUSERID = null; objKey.AMOUNT = Convert.ToDecimal("3.99"); objKey.DATECREATED = DateTime.Now; objKey.LAST4CC = "0002"; objKey.PAYMENTTYPEID = 1; objKey.PRIMARYAPPUSERID = user.ID; objKey.PROMOCODE = ""; objKey.PURCHASEDATE = DateTime.Now; objKey.SALESREPID = 1; objKey.SHAREKEYCODE = "20151022-0001"; objKey.ApplicationUser = user; result = obj.UpdateShareKey(appGlobal.username, appGlobal.password, objKey); }
protected void btnAddRemoveOrganization_Click(object sender, EventArgs e) { MyFileIt.MyFileItAppServiceClient svc = new MyFileIt.MyFileItAppServiceClient(); MyFileIt.MyFileItResult result = new MyFileIt.MyFileItResult(); //get all the associations for the user int appUserIDLookup = 5; //this id is valid on my LOCAL DB, NOT server int newOrganizationID = 25; int oldOrganizationID = 21; DateTime startDate = DateTime.Now; DateTime expiresDate = DateTime.Now.AddDays(10); int yearCode = 2015; int sportTypeID = 2; int appUserTypeID = 5; AppUserDTO user = null; result = svc.GetAppUsers(appGlobal.username, appGlobal.password, appUserIDLookup, null); user = result.AppUsers.First(); //loop all associated organization and remove specific organization //NOTE: I skipped all success / fail catch logic just to run the routine user.Organizations.Where(o => o.ID == oldOrganizationID || o.ID == newOrganizationID).ToList().ForEach(o => { svc.RemoveAppUserFromOrganization(appGlobal.username, appGlobal.password, user.ID, o.ID); }); //add the new organization link into the table result = svc.AssociateAppUserToOrganization(appGlobal.username, appGlobal.password, user.ID, appUserTypeID, newOrganizationID, startDate, expiresDate, yearCode, sportTypeID); lblMessage.Text = result.Success ? "Worked" : "Failed"; }