Question
Below is the code given, please find out the error in the code and provide the solution also provide what sort of packages should be
Below is the code given, please find out the error in the code and provide the solution also provide what sort of packages should be installed in the visual studio to get the code running.(windows)
using InterviewTest.DataAccess; using InterviewTest.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using System.Web.UI.WebControls;
namespace InterviewTest.Controllers.Home { public class HomeController : Controller {
HotelServiceReference1.HotelsSoapClient hotelSoapClient = new HotelServiceReference1.HotelsSoapClient("HotelsSoap"); HotelServiceReference1.HotelCredentials hotelCredential = new HotelServiceReference1.HotelCredentials();
public ActionResult Index() { try {
int y = 0; var x = 100 / y; hotelCredential.username = "aeTraining"; hotelCredential.password = "ZZZ"; return BannerTrackingReport(); } catch (Exception e) { //return View("Error"); ViewBag.ErrorMessage = e.Message; return View(); } //return View(); }
public ActionResult BannerTrackingReport() { // EXERCISE #1 CODE HERE List bannerlist; using (var db = new webappEntities()) {
bannerlist = db.vw_Banners.Select(a => new BannerViewModel() { BannerId = a.BannerId, Name = a.Name, Link = a.Link, TotalClickCount = a.TotalClickCount, TotalImpression = a.TotalImpression }).ToList();
}
return View(bannerlist); }
public ActionResult HotelsWebService() { // EXERCISE #2 CODE HERE
HotelServiceReference1.ImageOptions img = new HotelServiceReference1.ImageOptions(); hotelCredential.username = "aeTraining"; hotelCredential.password = "ZZZ"; var result = hotelSoapClient.GetHotel(hotelCredential, null, 105304);
var con = new HotelModel() { HotelID = result.HotelID, HotelName = result.Name, AirportCode = result.AirportCode, Address1 = result.Address1, Address2 = result.Address2, Address3 = result.Address3, City = result.City, State = result.StateProvince };
return View(con); }
[HttpGet] public ActionResult CustomValidator() { return View(); }
[HttpPost] public ActionResult CustomValidatorPost(CustomValidatorVM model) { if (model.region == null && model.state == null) { ViewBag.ErrorMessage = "Error: You should at least enter one Value"; return View("CustomValidator"); } return View("Welcome"); }
public ActionResult HelperSql() { //The db scripts are executed manually to the local database return View(); }
public ActionResult InsertBanner() { // EXERCISE #1 CODE HERE using (var db = new webappEntities()) { db.fn_proc_InsertBanner("asce", "http://asce.com", "asce.jpg"); }
return View(); } }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started