+1 voto
por felipe-jimenez (130 puntos) en Programación
Deseo poner a funcionar el el boton creaate , detail ,delete y Edit.

Tengo el siguiente codigo:

 

En el controlador :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ParaParcialFJMio.Models;

namespace ParaParcialFJMio.Controllers
{
    public class TareasController : Controller
    {
        // GET: Tareas
        public ActionResult Index()
        {

            List<Tareas> Lista = new List<Tareas>();

            Tareas Tar1 = new Tareas();
            Tar1.CodigoTarea = 1;
            Tar1.NombreTarea = "Tarea 1";
            Tar1.FechaTarea = new DateTime();
            Tar1.EstadoTarea = true;
            Lista.Add(Tar1);

            Tareas Tar2 = new Tareas();
            Tar2.CodigoTarea = 2;
            Tar2.NombreTarea = "Tarea 2";
            Tar2.FechaTarea = new DateTime();
            Tar2.EstadoTarea = true;
            Lista.Add(Tar2);

            Tareas Tar3 = new Tareas();
            Tar3.CodigoTarea = 3;
            Tar3.NombreTarea = "Tarea 3";
            Tar3.FechaTarea = new DateTime();
            Tar3.EstadoTarea = false;
            Lista.Add(Tar3);

            Tareas Tar4 = new Tareas();
            Tar4.CodigoTarea = 4;
            Tar4.NombreTarea = "Tarea 4";
            Tar4.FechaTarea = new DateTime();
            Tar4.EstadoTarea = false;
            Lista.Add(Tar4);

            Tareas Tar5 = new Tareas();
            Tar5.CodigoTarea = 5;
            Tar5.NombreTarea = "Tarea 5";
            Tar5.FechaTarea = new DateTime();
            Tar5.EstadoTarea = true;
            Lista.Add(Tar5);

            Tareas Tar6 = new Tareas();
            Tar6.CodigoTarea = 5;
            Tar6.NombreTarea = "Tarea 6";
            Tar6.FechaTarea = new DateTime();
            Tar6.EstadoTarea = false;
            Lista.Add(Tar6);

            return View(Lista);
        }

        public ActionResult Create()
        {

            return View();
        }

        public ActionResult Edit()
        {
            
            return View();
        }

        public ActionResult Delete()
        {

            return View();
        }

        public ActionResult Details()
        {

            return View();
        }

 

    }
}

En la vista Create.

@model ParaParcialFJMio.Models.Tareas

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Tareas</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.CodigoTarea, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.CodigoTarea, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.CodigoTarea, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.NombreTarea, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.NombreTarea, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.NombreTarea, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.FechaTarea, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.FechaTarea, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.FechaTarea, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.EstadoTarea, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.EditorFor(model => model.EstadoTarea)
                    @Html.ValidationMessageFor(model => model.EstadoTarea, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

 

 

 

y en la clase.

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ParaParcialFJMio.Models
{
    public class Tareas
    {
        public int CodigoTarea { get; set; }
        public string NombreTarea { get; set; }
        public DateTime FechaTarea{ get; set; }
        public Boolean EstadoTarea { get; set; }
    }
}

 

 

Agradezco si alguien me ayuda . Mi correo personal es feluis23_93@hotmail.com

Tu respuesta

Nombre a mostrar (opcional):
Privacidad: Tu correo electrónico sólo será utilizado para enviarte estas notificaciones.
Verificación anti-spam:
Para evitar esta verificación en el futuro, por favor identifícate o registrate.
...