none
login, redirect, armed, C # MVC3

    Question

  • Hello.

    I apologize for my first Indian middle translation.

    I am an understanding of code problems. I'm doing some work for the faculty. and was 2 my partner did his part but forget to give me a base with comments. for me to follow and is traveling. alcanze and outside so I could communicate with him and get me doubts.

    Languages: C # MVC3, SQL, Linq

    I wanted to see if anyone might have more idea that can understand more.

    work consists of these item. to consider

         The client is an educational institution.
         The customer wants to show his students notes for each subject.
             Students can view their grades entering a Web site with your file and password.
             The student can select the field by which you want to see your note.
                 The student will be able to comment on the proposed footnote.
         The client requires a Web interface easy to modify.
             The customer may require changes in the developmental stage.
         The database server is in a remote location.
             It is necessary to provide some mechanism to consume the information.
             In future implementations, you might need to show cell information.
         The logos, images and other graphical issues can be taken from the client's current website.
         You must ensure that only students can see notes.
             Students can only see their notes.
         A teacher might want to see all the notes and students associated with their subjects.

    Model



    the part where I am lost in the logon.

    first Question

    as remarked at the beginning, the work was done by 2. my question would be who is making this code because I fail to get a value and not be null.

    //show as ReturnUrl variable is generated
    
    public ActionResult LogOn(Login modelo, string returnUrl)
    
    //then later. is the code that I can not give you a non-null value
    
    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1
                            && returnUrl.StartsWith("/")
                            && !returnUrl.StartsWith("//")
                            && !returnUrl.StartsWith("/\\"))
                        {
                            return Redirect(returnUrl);
                        }
    



    second Question

    In the part of AccountController. Students need to be Redirected to VerNotas. but VerNotas not working properly.
    AccountController code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Entities;
    using System.Web.Security;
    using BRL;
    
    
    namespace SegundoParcial.Controllers
    {
        public class AccountController : Controller
        {
            [Authorize()]
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult LogOn()
            {
                return View();
            }
    
            [HttpPost]
            public ActionResult LogOn(Login modelo, string returnUrl)
            {
                string aux = new BRL.ServicioLog().ValidarPassword(modelo.Password, modelo.Email);
            
                
    
    
                    if (aux.Equals("alumno"))
                    {
    
                        FormsAuthentication.SetAuthCookie(modelo.Email, false);
    
                        Session["NombreUsuario"] = modelo.Email;
    
                        if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1
                            && returnUrl.StartsWith("/")
                            && !returnUrl.StartsWith("//")
                            && !returnUrl.StartsWith("/\\"))
                        {
                            return Redirect(returnUrl);
                        }
                        else
                        {
                            return RedirectToAction("VerNota", "Alumnos");
                        }
                    }
                    else
                    {
                        if (aux.Equals("profesor"))
                        {
                            FormsAuthentication.SetAuthCookie(modelo.Email, false);
    
                            Session["NombreUsuario"] = modelo.Email;
    
                            if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1
                                && returnUrl.StartsWith("/")
                                && !returnUrl.StartsWith("//")
                                && !returnUrl.StartsWith("/\\"))
                            {
                                return Redirect(returnUrl);
                            }
                            else
                            {
                                return RedirectToAction("VerAlumno", "Alumnos");
                            }
    
                        }
    
                        return View(modelo);
                    }
    
                }
        }
    }







    this window if I charge a student (and entered the database). eg "german@alumno" Password = "1234"
    and I should take VerNotas. but it tells me this error.



    code VerNotas

    @model  List<Entities.Nota>
               
    @{
        ViewBag.Title = "Ver Notas";
    }
    
    <h2>Ver Alumno</h2>
    @using(Html.BeginForm("VerNota","Alumnos", FormMethod.Get))
    {
        <div>
            Escriba su Legajo:
            @Html.TextBox("idAlumno")
            <input type="submit" value="Buscar" />
        </div>
    }
    <hr />
    @if (Model != null)
    {
        foreach(var item in Model)
        {
             <div>Materia: @item.NombreMateria</div>
            <div>Calificacion: @item.Calificacion</div>
            
        }
    
    }
    else
    {
        <h3>@ViewBag.Errores</h3>
    }




    I repeat the question is how to implement the validation of not null. the code as said above (AccountController).

    fourth question

    I wonder if it is possible at the Logon (as showed in the picture above). if you can add a button or a link to the View-> Create.
    reformulated. so that the user can, in the case of not having an account created. click this button and / or link. and said window fence "CrearAlumno".
    and good at it you can create a student.

    code Crear.

    @using Entities
    @model Alumno
    @{
        ViewBag.Title = "Crear Alumno";
    }
    
    <h2>Crear Alumno</h2>
    @using (Html.BeginForm())
    {
        <div>Nombre: @Html.TextBoxFor(modelo => modelo.Nombre)</div>
        <div>@Html.ValidationMessageFor(modelo => modelo.Nombre)</div>
        
        <div>Legajo: @Html.TextBoxFor(modelo => modelo.Legajo)</div>
        <div>@Html.ValidationMessageFor(modelo => modelo.Legajo)</div>
        
        <div>Domicilio: @Html.TextBoxFor(modelo => modelo.Domicilio)</div>
        
        <div>Email: @Html.TextBoxFor(modelo => modelo.Email)</div>
        <div>@Html.ValidationMessageFor(modelo => modelo.Email)</div>
        
        <div>Contraseña: @Html.PasswordFor(modelo => modelo.Password)</div>
        <div>@Html.ValidationMessageFor(modelo => modelo.Password)</div>
    
        <input type="submit" value="Enviar" />
        
        <div class="validation-summary-errors">@Html.ValidationSummary()</div>
    }
    



    fifth question

    a forum user (Leandro Tuttini). I recommended a few lines of code to prevent AUX remains equal to null.

    the problem is that I have not found how to implement it as being in a controller I have no direct access. to lbl or txt or messanger box and do not know how to show that the user is not or does not exist in the database.

    recommended code

    if(string.IsNullOrEmpty(aux)){
    
        lblMensaje.Text = "usuario o password invalidos";
    
        return;
    
    }
    

     if (userService.IsValidUser(model.Email, model.Password))
          {
    
             }
    


    how to implement it in AccoutControllers.


    an answer of this is gained wings.
    I will not forget any explanation if I miss something let me know I'll be outstanding to respond quickly.
    from and I thank you for your kindness
    Sunday, July 28, 2013 5:57 PM

All replies