Пример #1
0
 public ActionResult AddVehicle(ParkingPortal parkingPortal)
 {
     try
     {
         var    data    = parkingBussiness.AddData(parkingPortal);
         var    count   = parkingBussiness.CountSlot();
         bool   success = false;
         string message;
         if (data == null)
         {
             success = false;
             message = "Parking is Full";
             return(Ok(new { success, message }));
         }
         else
         {
             success = true;
             message = "Data Added Successfully";
             return(Ok(new { success, message, data }));
         }
     }
     catch (Exception)
     {
         bool   success = false;
         string message = "Invalid Data";
         return(BadRequest(new { success, message }));
     }
 }
Пример #2
0
 public ParkingPortal AddData(ParkingPortal parkingPortal)
 {
     try
     {
         var data = parkingRepository.AddData(parkingPortal);
         return(data);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
 public ParkingPortal AddData(ParkingPortal parkingPortal)
 {
     if (parkingPortal.Handicap == "Yes")
     {
         parkingPortal.Slot = "A";
     }
     parkingPortal.Status      = "Parked";
     parkingPortal.ParkingDate = DateTime.Now;
     parkingPortal.Slot        = CheckSlot();
     db.Add(parkingPortal);
     db.SaveChanges();
     return(parkingPortal);
 }
        public void AddingParkingDetails_ReturnOKResult()
        {
            ParkingPortal details = new ParkingPortal()
            {
                DriverName    = "ManishChandra",
                VehicleNumber = "MH47P 4521",
                Brand         = "Jaguar",
                VehicleColor  = "Black",
                Slot          = "D",
                Handicap      = "Yes",
                ParkingDate   = DateTime.Now,
                Status        = "Park"
            };

            // Act
            var okResult = parkingLotController.AddVehicle(details);

            // Assert
            Assert.IsType <OkObjectResult>(okResult);
        }
        public object GetVehicleByNo(string number)
        {
            ParkingPortal portal = new ParkingPortal();

            portal.VehicleNumber = number;
            try
            {
                if (db.parkingPortals.Any(p => p.VehicleNumber == number))
                {
                    return((from table in db.parkingPortals
                            where table.VehicleNumber == number
                            select table).ToList());
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }