3
I am developing an application that should provide an environment where the following functions are executed:
Administrator
- Cadastra questions
- Edits user
- View responses
- View evidence
- I inserted note
User
- Register
- Fill out evidence
In this environment the time will be timed based on the start time of the test that will be related to the time filled by the administrator in the evidence register. I thought of validating the time by jQuery just by entering in the database the initial time of the proof and comparing regardless of whether the user close the browser. As I will work with ajax, I will not worry about the user disabling javascript or not. Each question will be on a screen that will be made available via ajax and if it closes the browser and reopens, it will respond again in what stopped (without bringing what it filled in the same).
I created the following domains:
Pupil
public class Bolsa_Aluno
{
public int ID { get; set; }
[Required(ErrorMessage = "Nome deve ser preenchido")]
public string Nome { get; set; }
[Required(ErrorMessage = "Email deve ser preenchido")]
[RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "E-mail inválido")]
public string Email { get; set; }
[Required(ErrorMessage = "CPF deve ser preenchido")]
[StringLength(11, ErrorMessage = "Digite apenas 11 números")]
public string CPF { get; set; }
[Required(ErrorMessage = "Telefone deve ser preenchido")]
[StringLength(15, ErrorMessage = "Digite no máximo 15 caracteres")]
public string Telefone { get; set; }
public string Curso { get; set; }
public virtual int AlunoProvaID { get; set; }
public virtual Bolsa_AlunoProva AlunoProva { get; set; }
}
Alunoprova
public class Bolsa_AlunoProva
{
public int ID { get; set; }
public int Nota { get; set; }
public DateTime DataInicial { get; set; }
public DateTime DataFinal { get; set; }
public virtual int AlunoID { get; set; }
public virtual Bolsa_Aluno Aluno { get; set; }
public virtual int ProvaID { get; set; }
public virtual Bolsa_Prova Prova { get; set; }
public virtual ICollection<Bolsa_AlunoResposta> AlunoResposta { get; set; }
}
Alunoresposta
public class Bolsa_AlunoResposta
{
public int ID { get; set; }
public string Resposta { get; set; }
public virtual int AlunoProvaID { get; set; }
public virtual Bolsa_AlunoProva AlunoProva { get; set; }
public virtual ICollection<Bolsa_Pergunta> Pergunta { get; set; }
}
Question
public class Bolsa_Pergunta
{
public int ID { get; set; }
[Required(ErrorMessage = "Pergunta deve ser preenchido")]
public string Pergunta { get; set; }
public virtual int AlunoProvaID { get; set; }
public virtual Bolsa_AlunoProva AlunoProva { get; set; }
public virtual int AlunoRespostaID { get; set; }
public virtual Bolsa_AlunoResposta AlunoResposta { get; set; }
}
Proof
public class Bolsa_Prova
{
public int ID { get; set; }
[Required(ErrorMessage = "Tempo deve ser preenchido em minutos")]
public int Tempo { get; set; }
[Required(ErrorMessage = "Quantidade de Perguntas deve ser preenchido")]
public int QuantidadePerguntas { get; set; }
public string Nome { get; set; }
public string Bandeira { get; set; }
public virtual ICollection<Bolsa_Pergunta> Pergunta { get; set; }
}
My question is as follows. This is the best practice of validation and storage as long as I don’t have to worry extremely much about security?
It is bad practice to save each response individually in the database to "keep the session" if the user closes the browser?
While running Migration (code-first work), I came across the following relationship error:
Unable to determine the main end of an Association between the types 'Dominio.Bolsa_alunoprova' and 'Dominio.Bolsa_aluno'. The main end of this Association must be explicitly configured using either the Relationship Fluent API or data Annotations.
It would be correct to apply as a solution to the tag [Required]
in Bolsa_AlunoProva
in the item public virtual Bolsa_Prova Prova { get; set; }
?
I’ve never seen the term tag for what is officially called an attribute. It is still an attribute :)
– Maniero