public SlotModel GetSlotByNumber(string inputId)
        {
            SlotModel result = new SlotModel();
            using (SmartParkingEntities context = new SmartParkingEntities())
            {
                var qry = context.SlotMasters.Where(s => s.SlotNumber == inputId).SingleOrDefault();

                if (qry != null)
                {
                    result = ConvertDBToModelObject(qry);
                }
            }
            return result;
        }
 public async Task<PartialViewResult> GetSlotEditForm(int slotID)
 {
     SlotModel slot = new SlotModel();
     using (var client = new HttpClient())
     {   
         string url = System.Configuration.ConfigurationManager.AppSettings["SmartParkingAPI"];
         client.BaseAddress = new Uri(url);
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         HttpResponseMessage response = await client.GetAsync("api/Slotmaster/GetSlotByID/" + slotID);
         if (response.IsSuccessStatusCode)
         {
             slot = await response.Content.ReadAsAsync<SlotModel>();
         }
     }
     ViewBag.Mode = "Edit";
     return PartialView("_AddSlot", slot);
 }
 public async Task<ActionResult> UpdateSlot(SlotModel slotModel)
 {
     //bool result=false;            
     using (var client = new HttpClient())
     {
         string url = System.Configuration.ConfigurationManager.AppSettings["SmartParkingAPI"];
         client.BaseAddress = new Uri(url);
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         HttpResponseMessage response = await client.PostAsJsonAsync("api/SlotMaster/PostUpdateSlotMaster", slotModel);
         if (response.IsSuccessStatusCode)
         {
             result = await response.Content.ReadAsAsync<bool>();
         }
     }
     return Json(result);
 }
        public bool PostUpdateSlotMaster(SlotModel slot)
        {
            bool result = false;
            using (SmartParkingEntities context = new SmartParkingEntities())
            {
                SlotMaster updateSlot = context.SlotMasters.Where(s => s.ParkingID == slot.ParkingID && s.SlotID==slot.SlotID).SingleOrDefault();
                updateSlot.SlotNumber = slot.SlotNumber;
                updateSlot.IsActive = slot.IsActive;
                updateSlot.IsAcquired = slot.IsAcquired;

                context.SaveChanges();
                result = true;
            }
            return result;
        }
        public bool PostSlotMaster(SlotModel slot)
        {
            bool result = false;
            using (SmartParkingEntities context = new SmartParkingEntities())
            {
                SlotMaster parlSlot = new SlotMaster()
                {
                    ParkingID = slot.ParkingID,
                    SlotNumber = slot.SlotNumber,
                    IsAcquired = slot.IsAcquired,
                    IsActive = slot.IsActive
                };

                context.SlotMasters.Add(parlSlot);
                context.SaveChanges();
                result = true;
            }
            return result;
        }