Group 6 - Showroom With MVC

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 24

ShowroomCar with MVC

Group 6

Names : -Muhartsal Raihan

-Hafizh Zaldy Alviansyah

Class : 4WD1

CEP CCIT

FAKULTAS TEKNIK UNIVERSITAS INDONESIA

2021
PROJECT ON

ShowroomCar

Developed by

1. Muhartsal Raihan
2. Hafizh Zaldy Alviansyah

2
ShowroomCar with MVC

Batch Code : -

Start Date : 01/07/2022


End Date : 06/07/2022

Name of Faculty : Indah Ayu

Names of Developer :

1. Muhartsal Raihan
2. Hafizh Zaldy Alviansyah

Date of Submission: 06/07/2022

3
CERTIFICATE

This is to certify that this report titled “ShowroomCar with MVC“ embodies the original
work done by Muhartsal Raihan and Hafizh Zaldy Alviansyah. Project in partial fulfillment
of their course requirement at NIIT.

Coordinator:

Indah Ayu

4
ACKNOWLEDGEMENT

Praise and gratitude the author goes to the presence of God Almighty for His blessings
and grace, we were able to complete this project task both in the form of presentations and
papers on time.

The author also thanks Indah Ayu and other lecturers for all their guidance to
complete it. Thank you to fellow students who have supported, and also thank you to fellow
education staff at CCIT-FT UI. Project Paper entitled “ShowroomCar with MVC” which the
author submitted as a requirement for Project assignment in 2022.

Finally, the author hopes that this paper can be useful for all and also add a better
insight into the operating system. The author realizes that it is still not perfect. Therefore, the
author expects all suggestions and criticisms from readers that are constructive for the
perfection of this paper. Hopefully this paper can provide many benefits for readers.

5
System Analysis

System summary:
Showroom Car is an MVC-based program from Visual Studio Community 2017. With this
Showroom Car program, users can add the latest car products and change them. This program
uses a programming language that combines Cs and XHTML to get more structured and
orderly coding results. As well as using a database from SQL Management Studio 2014

To get a more attractive web appearance, we use an open source html, css, java script
framework from bootstrap to design responsive websites easily and quickly.

Before using this program, users are required to enter login authentication on the login page.
If the user has successfully entered the login identity, it will be directed to the home page.
In home page, users can search products of car

6
ERD DIAGRAM

7
HOME CONTROLLER IMPLEMENTATION

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShowroomCar.Models;
namespace ShowroomCar.Controllers
{
public class HomeController : Controller
{
DBShowroomCarEntities dB = new DBShowroomCarEntities();
// GET: Home
public ActionResult Index(string Searching)
{
return View(dB.Product.Where(x => x.ProductName.Contains(Searching) || Searching ==
null).ToList());
}
public ActionResult SignUp()
{
return View();
}
[HttpPost]
public ActionResult SignUp(UserLogin userLogin)
{
if (dB.UserLogin.Any(x=>x.Username==userLogin.Username))
{
ViewBag.Notification = "This Account Has Already Existed";
return View();
}
else
{
dB.UserLogin.Add(userLogin);
dB.SaveChanges();
Session["ids"] = userLogin.id.ToString();
Session["usernames"] = userLogin.Username.ToString();
return RedirectToAction("Index", "Home");
}
}
public ActionResult LogOut()
{
Session.Clear();
return RedirectToAction("Index", "Home");
}
[HttpGet]
public ActionResult Login()
{
return View();
}

8
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(UserLogin userLogin)
{
var CheckLogin = dB.UserLogin.Where(x =>
x.Username.Equals(userLogin.Username) &&
x.Password.Equals(userLogin.Password)).FirstOrDefault();
if (CheckLogin != null)
{
Session["ids"] = userLogin.id.ToString();
Session["usernames"] = userLogin.Username.ToString();
return RedirectToAction("UserDashboard");
}
else
{
ViewBag.Notification = "Wrong Username Or Password";
}
return View();
}
public ActionResult UserDashboard()
{
if (Session["ids"] != null)
{
return View();
}
else
{
return RedirectToAction("Index", "Home");
}
}
}

9
PRODUCT CONTROLLER IMPLEMENTATION

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using ShowroomCar.Models;

namespace ShowroomCar.Controllers
{
public class ProductController : Controller
{
private DBShowroomCarEntities db = new DBShowroomCarEntities();

// GET: Product
public ActionResult Index()
{
var product = db.Product.Include(p => p.Brand).Include(p => p.Category);
return View(product.ToList());
}

// GET: Product/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Product product = db.Product.Find(id);
if (product == null)
{
return HttpNotFound();
}
return View(product);
}

10
// GET: Product/Create
public ActionResult Create()
{
ViewBag.Brand_ID = new SelectList(db.Brand, "id", "Brand1");
ViewBag.Category_ID = new SelectList(db.Category, "id", "Category1");
return View();
}

// POST: Product/Create
// To protect from overposting attacks, please enable the specific properties you
want to bind to, for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include =
"id,ProductName,Category_ID,Brand_ID,Quantity,Price")] Product product)
{
if (ModelState.IsValid)
{
db.Product.Add(product);
db.SaveChanges();
return RedirectToAction("Index");
}

ViewBag.Brand_ID = new SelectList(db.Brand, "id", "Brand1", product.Brand_ID);


ViewBag.Category_ID = new SelectList(db.Category, "id", "Category1",
product.Category_ID);
return View(product);
}

// GET: Product/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Product product = db.Product.Find(id);
if (product == null)
{
return HttpNotFound();
}
ViewBag.Brand_ID = new SelectList(db.Brand, "id", "Brand1", product.Brand_ID);
ViewBag.Category_ID = new SelectList(db.Category, "id", "Category1",
product.Category_ID);
return View(product);
}

11
// POST: Product/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to,
for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "id,ProductName,Category_ID,Brand_ID,Quantity,Price")]
Product product)
{
if (ModelState.IsValid)
{
db.Entry(product).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.Brand_ID = new SelectList(db.Brand, "id", "Brand1", product.Brand_ID);
ViewBag.Category_ID = new SelectList(db.Category, "id", "Category1", product.Category_ID);
return View(product);
}

// GET: Product/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Product product = db.Product.Find(id);
if (product == null)
{
return HttpNotFound();
}
return View(product);
}

// POST: Product/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Product product = db.Product.Find(id);
db.Product.Remove(product);
db.SaveChanges();
return RedirectToAction("Index");
}

protected override void Dispose(bool disposing)


{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}

12
CATEGORY CONTROLLER IMPLEMENTATION

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using ShowroomCar.Models;

namespace ShowroomCar.Controllers
{
public class CategoryController : Controller
{
private DBShowroomCarEntities db = new DBShowroomCarEntities();

// GET: Category
public ActionResult Index()
{
return View(db.Category.ToList());
}

// GET: Category/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Category category = db.Category.Find(id);
if (category == null)
{
return HttpNotFound();
}
return View(category);
}

// GET: Category/Create
public ActionResult Create()
{
return View();
}

// POST: Category/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to,
for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]

13
public ActionResult Create([Bind(Include = "id,Category1")] Category category)
{
if (ModelState.IsValid)
{
db.Category.Add(category);
db.SaveChanges();
return RedirectToAction("Index");
}

return View(category);
}

// GET: Category/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Category category = db.Category.Find(id);
if (category == null)
{
return HttpNotFound();
}
return View(category);
}

// POST: Category/Edit/5
// To protect from overposting attacks, please enable the specific properties
you want to bind to, for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "id,Category1")] Category category)
{
if (ModelState.IsValid)
{
db.Entry(category).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(category);
}

// GET: Category/Delete/5

14
// GET: Category/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Category category = db.Category.Find(id);
if (category == null)
{
return HttpNotFound();
}
return View(category);
}

// POST: Category/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Category category = db.Category.Find(id);
db.Category.Remove(category);
db.SaveChanges();
return RedirectToAction("Index");
}

protected override void Dispose(bool disposing)


{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}

15
BRAND CONTROLLER IMPLEMENTATION

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using ShowroomCar.Models;

namespace ShowroomCar.Controllers
{
public class BrandController : Controller
{
private DBShowroomCarEntities db = new DBShowroomCarEntities();

// GET: Brand
public ActionResult Index()
{
return View(db.Brand.ToList());
}

// GET: Brand/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Brand brand = db.Brand.Find(id);
if (brand == null)
{
return HttpNotFound();
}
return View(brand);
}

// GET: Brand/Create
public ActionResult Create()
{
return View();
}

// POST: Brand/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to,
for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "id,Brand1")] Brand brand)
{
if (ModelState.IsValid)
{

16
{
db.Brand.Add(brand);
db.SaveChanges();
return RedirectToAction("Index");
}

return View(brand);
}

// GET: Brand/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Brand brand = db.Brand.Find(id);
if (brand == null)
{
return HttpNotFound();
}
return View(brand);
}

// POST: Brand/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to,
for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "id,Brand1")] Brand brand)
{
if (ModelState.IsValid)
{
db.Entry(brand).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(brand);
}

// GET: Brand/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Brand brand = db.Brand.Find(id);
if (brand == null)
{
return HttpNotFound();
}

17
}
return View(brand);
}

// POST: Brand/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Brand brand = db.Brand.Find(id);
db.Brand.Remove(brand);
db.SaveChanges();
return RedirectToAction("Index");
}

protected override void Dispose(bool disposing)


{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}

18
INTERFACE DESIGN

Login Page

19
INTERFACE DESIGN

Home Page

20
INTERFACE DESIGN

Category Page

21
INTERFACE DESIGN

Brand Page

22
INTERFACE DESIGN

Product Page

23
CONFIGURATION

Hardware: ATI Radeon AMD A8 4500-APU HD Graphic

Operating System: Windows 7

Software: Microsoft Visual Studio 2017,SQL Server Management Studio 2014

PROJECT FILE DETAILS

S.No File Name Remarks


Showroomcar with MVC.docx The Microsoft Word Document Of
Makalah Project 2 Semester 4 CEP
CCIT FTUI

24

You might also like