Ways of retaining data from web form - asp.net-mvc

I have a function to code where I need to enter details of an student in a web form.
The system will do 2 verifications:
If the email address of the student is in the system.
If the name of the student is in the system.
If any of the above is true then the system will send the list of matches in a new page for user of system to check if the student is already in the system or not. If not, the new student is created in system by clicking on the create new button in the web page.
My question is how do I store the information obtained in the 1st web form so as to be able to create a new student in case it does not exit. Do I need to create a new model to collect the details from the 1st web form or is there any other way of doing this? Cause I will not be needing the web form data if the student already exist.
I am coding in .net 4.6 and MVC5.

Related

Form settings validation (application and form name uniqueness)

From the Orbeon documentation:
Application Name. Each form definition has an application name which identifies a group of forms that belong together. In practice, an application name might correspond to a project, or a department, or a company. For example, all forms built by Orbeon have the "orbeon" application name.
NOTE: Depending on your permissions, the application name might have been picked for you already, or you might have the choice of a restricted set of application names.
Form Name. Each form definition also has a form name, which identifies a unique form name within a particular application.
As orbeon's persistence API retrieves the form definitions by their application and form name, I would like to put some validation to the form settings page that would prevent the user to save a second from definition with the same application and form name as an existing one.
(My first approach would be to put some custom response to the persistence layer, but orbeon is not able to make difference between a general persistence error and a validation errror there with other words the backpropagation of the errors of the persistence layer/api to the user is not that mature, so to say.)
So how should I do this?
If I understand correctly, you'd like Form Builder users to be prevented from creating a new form with an app/form name that is already used. The user could either be prevented from creating that form, or at least offered the option of opening the existing form instead of creating a new one with the same app/form name.
One question would be what, in that context, "already used" means: are we talking about forms editable by that user in Form Builder, or published forms? Maybe Form Builder should check both.
This check should happen in 3 places in Form Builder:
When the form is initially created (better warn users as soon as possible).
When users open the form settings dialogue to rename the form.
When saving (even if we're sure no form with the same app/name existed at the time the form was created, in the meantime another form with the same app/name might have been created).
In situation number one, if a form with the same app/name exists in Form Builder, Form Builder should provide the user the option to open that form instead of creating a new form.
So this is a feature that should be implemented at the level of Form Builder; it cannot be done solely by a custom implementation of the persistence API. This is covered by request for enhancement #818.

how to edit and commit a domain with its hasmany domain

I'm currently have the task to move our java-application code to a web-application.
I would decide to use grails for this task. (I developed already a few simple applications in grails and they worked nicely.)
But with one behaviour, I have my serious problems.
Giving a domain model with:
a customer has many addresses
an address belongs to customer and has many contacts
a contact belongs to address
edit: Because I use the "belongsTo" setting, the cascading save would not be a problem (I think).
What I would need:
While creating a customer I need the possibility to attach a few addresses and there I should have the possibility to add a few contacts.
But all should be committed to the database after pressing the save button in the customer view. (The same with editing a customer...)
Current behaviour:
With the default controllers and views, I first need to commit the customer and could than add the addresses the same with the contacts (first commit the address and than add the contacts).
edit:
(as I understand correctly) the data binding is used by default in the "generate-controller" and "generate-view" resulting classes.
The thing where I have no idea is, how to handle the web-page-flow, that I could add an address and there a few contacts, without saving the customer domain before. And after switching several times between the views "customer.create", "address.create" and "contact.create" having the whole structure still present.
(I tried to save the customer-domain in the session-object and in the create.address view save-method, I fetched the customer from the session and added the addressInstance to the address-list of the customer, saved the customer again in the session and switched back to a new editSession-action for the customerInstance which fetches the instance to be edited from the session. But it seemed to me, that only the customerInstance is contained in the session and not the associated objects... [omg, hope I could make me understand...])
Would my needed workflow somehow be possible? (Hopefully you could point me to some documentation or examples, please)
Thanks in advance,
Susanne.
There are many possibilities, here are a few suggestions that may help you find a solution:
The user friendliest design is to create all three objects on the same page (Why would a user want to switch between three screens to setup a new Customer?). This takes a bit more work on the page but you can create/edit and save the customer in one go.
If you have separate screens to add Customer, Address & Contact let the user start with creating the customer. save it. When the user adds an Address pass along the Customer id. save it linked to the Customer (you have the id). Same for Contacts.
If you don't want the user to explicitly save the Customer before he can add an Address you can save the Customer automatically when the user clicks "add address" on the Customer page. Same for Contacts.
If you don't want to show the unfinished customer to someone else you can add an in creation flag on the customer to filter unfinished Customers (or you use another table to link to unfinished users, if you dislike the 'state' information on the customer). When the user finally decides the Customer is ready (pressing save on the Customer page) you clear the unfinished state (or remove it from the unfinished table) to make the new Customer visible to all users.
Doing it like this you could even recover from session timeouts and offer the user to continue creation of the customer.

populating model through rest api

I'm currently working on a rails app where I have two model classes, Account and User. I want to allow users to link their User with account information from other places.
What I want the user to be able to do is, under my edit user form, I have a list displaying the names of all linked accounts, and a text input for them to add more.
All I want them to do is fill in one field (account name) and hit a button, and the back end will hit a restful API for that account name, pull back relevant info, and populate an Account model object, linking to the current user.
For example, from the user page I would like the user to be able to type in their twitter handle, and in the back end I'd look up that twitter account id and associate it with that User in my database.
Where is the right place to have a hook so that I can take an input (twitter handle), fire off a helper method that populates a Account object, and then link that to my current user?
I'm not sure I understood exactly what you were asking but I'll try my best : If your account 'belongs_to' your User model, it would seem logical to use the create or update method (depending on your standard case) of your Accounts controller, to retrieve a JSON with the accounts datas, and that the client parse this answer (with some JS).

.net mvc Foreign Key Relationships with Active Directory

I am developing an Intranet application and have successfully integrated with Active Directory.
When we add a new customer I would like to assign a Customer Advisor from a dropdown list.
I am able to populate the dropdown list using the following
PrincipalContext pc = new PrincipalContext(ContextType.Domain, "DOMAIN", "dc=domain,dc=org");
GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, "customerAdvisors");
ViewBag.Guid = new SelectList(group.Members, "Guid", "DisplayName");
I would like to then store the Guid of the selected user along with the Customer data in the database.
However, I am unsure of how to setup foreign key constraints in my Model as the table I am joining to is within Active Directory.
Do I need to create a separate Employee table within my DB and sync the required fields or is there a simplified way of doing this?
I've never done this but some quick research makes it look possible.
You could just save the Guid for your adviser on your Customer. The AD Guid can go into the Guid data type. You should be able to query individual users by using this method:
UserPrincipal user =
UserPrincipal.FindByIdentity(pc, yourUsersGuidAsAString);
The down side is that every time you want your customer adviser's info (like their name or email address) you will have to do a separate query to AD. Harder to use ORM.
In my application I have a different use case, but I have also integrated my application with AD. The route that I took was to save this information in my own DB instead of hitting AD every time. In large part because my architecture makes it hard to get to AD in the same way you can. Also it's easier to use ORM (like entity framework in my case) to pull in the information that I want. The downside to this is then you need to ensure that the information you have in your database is reasonably up to date with what's in AD.
You will have to make the judgement on which approach makes the most sense for your architecture/use case.
Hope that helps.

How to dynamically populate Jira custom fields?

I'm new to the Jira admin side of things after having used it in a previous company as an end-user for several years. We are using the standard Jira workflow. The scenario I'm struggling with is the following. I'm attempting to match some of the functionality of our old-proprietary issue database. Right now I'm using many of the standard Jira fields, with only two new custom fields (both single Select Lists populated manually by me):
1) Customer = customer name who sent the new issue email to our support team
2) Customer Contact = the main customer contact, currently populated by the custom list
I created these two custom fields because we have external customers who call or email issues they have using our hosted software. Currently our system creates a simple new issue when a customer sends an email to our support email account. Our support team then goes in and cleans up the data and makes sure that all the required Jira fields have data, the comments are good, reproducible steps, etc. (Currently we do not strip out the customer domain name to auto-populate the Customer custom field, but I might try doing that soon.)
Our support team is asking that I add the following two new customer fields:
3) Customer phone number
4) Customer connection / login info
What I would like to implement is a system that goes something like this:
Customer name gets inputted (either automatically by grabbing domain name of customer email address or manually by our support team) into the Customer custom field. Customer name selected should be "pushed" into the Customer Contact Select List to help sub-select values for that particular customer.
The Customer Contact Select list should be "smart" or dynamic in that some pre-processing is done where the Customer name is grabbed so that it doesn't show ALL customers contacts for the tech support person to select, it just shows them the customer contacts for the customer that was selected.
Along with the filtered customer contacts, I would want to only see the Customer phone number for the contact that was populated in the Customer Contact select list.
And finally I would want to see the Customer connection information for the particular Customer that was selected.I've done this type of smart combo boxes in the past when I created Java / Database applications, so I have a feeling that this is possible in Jira. I'm just looking for the easiest way to implement this. It seems like there might be some external plugins that might help do this (ex. the values for the Custom fields are stored in a database table so they can be queried and the proper filtered result sets can be populated into the select lists.), or maybe using post functions (update issue), etc. But before I spent more effort investigating, I know this sort of thing has to be somewhere common and wanted to ask the Jira admin experts what the best practice would be for this type of functionality in custom fields. Please share your experience with how to solve this type of scenario. Thanks in advance!
Here is the way that tells how to import multiple options at once. Probably that would help u.
https://answers.atlassian.com/questions/92385/importing-project-from-another-jira-instance-how-do-we-mass-import-custom-field-multi-select-options?page=1#92622
EDIT
and here is the complete code to update another select list using new select list.
How to add new values to select list field in jira dynamically or using plug-in

Resources