Example #1
0
 static void Main(string[] args)
 {
     DBContext         dBContext         = new DBContext();
     InspectionUtility inspectionUtility = new InspectionUtility();
     var data = inspectionUtility.
                FilterByPlateNumber(DateTime.Now.Year, 33, "12CB45");
 }
        public ActionResult Create(Inspection inspection)
        {
            inspection.Amount = 50;
            inspection.Week   = commonUtility.
                                GetWeekNumber(inspection.InspectionDate);
            var data = inspectionUtility.
                       FilterByPlateNumber(inspection.InspectionDate.Year, inspection.Week, inspection.Truck.PlateNumber);

            if (data.Count() == 0)
            {
                if (ModelState.IsValid)
                {
                    inspectionRepository.Add(inspection);
                    return(RedirectToAction("Index", "Inspection"));
                }
            }
            else
            {
                TempData["Message"] = "Please try with another Plate , because this truck has already inspection for this week";
                return(RedirectToAction("Messages", "Inspection"));
            }

            return(View(inspection));
        }