mvc controller
mvc controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RGDefenceAcademy.Models;
namespace RGDefenceAcademy.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
return View();
}
public ActionResult AdmissionForm()
{
return View();
}
public ActionResult LogIn()
{
return View();
}
[HttpPost]
public ActionResult LogIn(string username, string pword)
{
if (username == "RGAdmin" && pword == "rg@123")
{
Session["username"] = username;
Response.Write("<script>alert('Welcome to Admin Zone
');window.location.href='/Admin/Index'</script>");
}
else
{
Response.Write("<script>alert('Invalid AdminId or
Password')</script>");
}
return View();
}
Admin Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RGDefenceAcademy.Models;
namespace RGDefenceAcademy.Controllers
{
public class AdminController : Controller
{
//
// GET: /Admin/
}
else
{
Response.Write("<script>alert('Logout');window.location.href='/Home/LogIn'</script>");
}
return View();
}
}
else
{
Response.Write("<script>alert('Logout');window.location.href='/Home/Login'</script>");
}
return View();
}
[HttpPost]
public ActionResult StudentAdmission(Tbl_Admission model, string submit)
{
try
{
return View(model);
}
[HttpPost]
public void UpdateStudentAdmission(Tbl_Admission model)
{
try
{
Tbl_Admission up = db.Tbl_Admission.SingleOrDefault(a => a.StudentId ==
model.StudentId);
up.StudentName = model.StudentName;
up.FatherName = model.FatherName;
up.MotherName = model.MotherName;
up.Class = model.Class;
up.DateOfBirth = model.DateOfBirth;
up.Gender = model.Gender;
up.MobileNo = model.MobileNo;
up.Address = model.Address;
db.SaveChanges();
Response.Write("<script>alert('Student Information Updated
Successfully');window.location.href='/Admin/StudentList'</script>");
}
else
{
Response.Write("<script>alert('Kindly upload your
profile');window.location.href='/Admin/UpdateStudentAdmission'</script>");
}
}
catch (Exception ex)
{
Response.Write("<script>alert('some thing went
wrong');window.location.href='/Admin/UpdateStudentAdmission'</script>");
}
}
public ActionResult StudentList()
{
return View(db.Tbl_Admission.ToList());
}
return View(model);
}
[HttpPost]
public void UpdateFaculty(Tbl_Faculity model)
{
try
{
Tbl_Faculity up = db.Tbl_Faculity.SingleOrDefault(a => a.FaculityId ==
model.FaculityId);
up.FaculityName = model.FaculityName;
up.Degination = model.Degination;
up.Qualifaction = model.Qualifaction;
up.MobileNo = model.MobileNo;
up.Gender = model.Gender;
up.Address = model.Address;
db.SaveChanges();
Response.Write("<script>alert('Faculty Information Updated
Successfully');window.location.href='/Admin/facultyList'</script>");
}
else
{
Response.Write("<script>alert('Kindly upload your
profile');window.location.href='/Admin/UpdateStudentAdmission'</script>");
}
}
catch (Exception ex)
{
Response.Write("<script>alert('Some thing went
wrong');window.location.href='/Admin/UpdateStudentAdmission'</script>");
}
}
return View(model);
}
[HttpPost]
public ActionResult UpdateGallery(Tbl_Gallery model,int GalleryId)
{
try
{
Tbl_Gallery up = db.Tbl_Gallery.SingleOrDefault(a => a.GalleryId == model.GalleryId);