public PlaneSeatClassModel CreateViewModel(PlaneSeatClass model) { PlaneSeatClassModel viewModel = null; if (model != null) { viewModel = new PlaneSeatClassModel(); CommonMethods.CopyObjectProperties(model, viewModel); } return(viewModel); }
private void UpdatePlaneSeatClass(PlaneSeatClassModel seatClass, int planeId, int capacity, double price, int seatClassID) { if (seatClass != null) { seatClass.Capacity = capacity; seatClass.Price = price; this.PlaneSeatClassService.Update(seatClass); } else if (capacity > 0) { var order = this.PlaneSeatClassService.FindByPlane(planeId).Select(planeSeat => planeSeat.Order).Max(); var planeSeatClass = new PlaneSeatClassModel { PlaneID = planeId, SeatClassID = seatClassID, Capacity = capacity, Price = price, Order = (order == null) ? 1 : ++order }; this.PlaneSeatClassService.Insert(planeSeatClass); } }
public void Update(PlaneSeatClassModel planeSeatClassairport) { this.PlaneSeatClassRepository.Update(planeSeatClassairport.GetModel()); this.UnitOfWork.SaveChanges(); }
public void Insert(PlaneSeatClassModel planeSeatClass) { this.PlaneSeatClassRepository.Insert(planeSeatClass.GetModel()); }
public ActionResult AddNewPlane(FormCollection collection) { var plane = new PlaneModel { Airline = collection.Get("airline"), SeatMapID = int.Parse(collection.Get("planetype")), Status = Constant.CONST_PLANE_STATUS_READY }; var planeID = this.PlaneService.Insert(plane); var firstclass = int.Parse(collection.Get("firstclass")); var business = int.Parse(collection.Get("business")); var economy = int.Parse(collection.Get("economy")); var order = 1; //for FirstClass if (firstclass > 0) { var planeSeatClass = new PlaneSeatClassModel { PlaneID = planeID, SeatClassID = Constant.CONST_DB_SEAT_CLASS_FIRSTCLASS_ID, Capacity = firstclass, Price = double.Parse(collection.Get("firstclassprice")), Order = order++ }; this.PlaneSeatClassService.Insert(planeSeatClass); } //for Business if (business > 0) { var planeSeatClass = new PlaneSeatClassModel { PlaneID = planeID, SeatClassID = Constant.CONST_DB_SEAT_CLASS_BUSINESS_ID, Capacity = business, Price = double.Parse(collection.Get("businessprice")), Order = order++ }; this.PlaneSeatClassService.Insert(planeSeatClass); } //for Economy if (economy > 0) { var planeSeatClass = new PlaneSeatClassModel { PlaneID = planeID, SeatClassID = Constant.CONST_DB_SEAT_CLASS_ECONOMY_ID, Capacity = economy, Price = double.Parse(collection.Get("economyprice")), Order = order++ }; this.PlaneSeatClassService.Insert(planeSeatClass); } var air = collection.Get("airport").Split(','); foreach (var a in air) { var planeAirport = new PlaneAirportModel { PlaneID = planeID, AirportID = int.Parse(a) }; this.PlaneAirportService.Insert(planeAirport); } TempData["msg"] = "success-Plane add successfully"; return(RedirectToAction("Index")); }