// GET: UpdateSessionPrice public ActionResult Index(long id) { TempData["slotViewList"] = null; SlotViewModel slotViewModel = new SlotViewModel() { SessionId = id }; HttpResponseMessage response = new APIHelper.APICallMethod().GetHttpResponseMessage("GetAllActiveSlotBySessionId", "AdminPanel", slotViewModel); if (response.IsSuccessStatusCode) { var data = response.Content.ReadAsStringAsync().Result; ViewModel.ResponseModel.ResponseViewModel <List <ViewModel.SlotViewModel> > dbBookingDetails = JsonConvert.DeserializeObject <ViewModel.ResponseModel.ResponseViewModel <List <ViewModel.SlotViewModel> > >(data); if (dbBookingDetails.IdentityResult.Status == true) { TempData["slotViewList"] = dbBookingDetails.Content; } else { // return Json(new { code = -1, message = dbBookingDetails.IdentityResult.Message }); } } else { // return Json(new { code = -2, message = "failed" }); } return(View()); }
public IActionResult GetSlot(int id) { List <SlotViewModel> Listmodel = new List <SlotViewModel>(); SlotViewModel model = null; var slots = _context.slots .Include(p => p.Parking) .Where(p => p.Parking.ParkingId == id); foreach (var slot in slots) { model = new SlotViewModel() { SlotId = slot.SlotId, SlotNo = slot.No, ParkingId = slot.Parking.ParkingId, ParkingName = slot.Parking.Name, IsReserved = slot.Reserved }; Listmodel.Add(model); } return(new OkObjectResult(Listmodel)); }
/// <summary> /// Get All Active Time Slot Detail /// </summary> /// <returns></returns> private List <SlotViewModel> GetAllSlotTime() { SlotViewModel slotViewModel = new SlotViewModel() { }; HttpResponseMessage response = new APIHelper.APICallMethod().GetHttpResponseMessage("GetAllTimeSlot", "AdminPanel", slotViewModel); if (response.IsSuccessStatusCode) { var data = response.Content.ReadAsStringAsync().Result; ViewModel.ResponseModel.ResponseViewModel <List <ViewModel.SlotViewModel> > dbBookingDetails = JsonConvert.DeserializeObject <ViewModel.ResponseModel.ResponseViewModel <List <ViewModel.SlotViewModel> > >(data); if (dbBookingDetails.IdentityResult.Status == true) { return(dbBookingDetails.Content); } else { return(new List <SlotViewModel>()); } } else { return(new List <SlotViewModel>()); } }
private void PopulateHelperProperties(SlotViewModel model) { _dataProtector.ProtectSlotRouteValues(model); _dataProtector.ProtectBookingRouteValues(model.BookingViewModels); if (model.IsBooked) { if (model.BookingViewModels.Any()) { if (model.BookingViewModels.Any(b => b.IsActive)) { model.CanMakeAvailable = true; model.Status = "Booked"; } else { model.CanDelete = true; model.CanEnableBooking = true; model.Status = "Booking Disabled"; } } else { model.CanDelete = true; model.CanEnableBooking = true; model.Status = "Booking Disabled"; } } else { model.Status = "Available"; model.CanDelete = true; model.CanDisableBooking = true; } }
public async Task <ActionResult <IEnumerable <Slot> > > Getslots() { SlotViewModel model = null; List <SlotViewModel> list = new List <SlotViewModel>(); var userId = _caller.Claims.Single(c => c.Type == "id"); var OnlineUser = await _userManager.FindByIdAsync(userId.Value); var parking = _context.parkings.Include(p => p.appUser) .FirstOrDefault(p => p.appUser.Id == OnlineUser.Id); var slots = await _context.slots.Include(p => p.Parking). Where(p => p.Parking.ParkingId == parking.ParkingId) .ToListAsync(); foreach (var slot in slots) { model = new SlotViewModel() { SlotNo = slot.No, SlotId = slot.SlotId, Parking = slot.Parking.Name, IsReserved = slot.Reserved }; list.Add(model); } return(new OkObjectResult(list)); }
/// <summary> /// Save Time Slot Details /// </summary> /// <param name="timeSlot">New Time For Save</param> /// <returns>Return Success Or Failed</returns> public JsonResult SaveTimeSlot(TimeSpan timeSlot) { SlotViewModel slotViewModel = new SlotViewModel() { Time = timeSlot }; HttpResponseMessage response = new APIHelper.APICallMethod().GetHttpResponseMessage("SaveSlotTimeDetail", "AdminPanel", slotViewModel); if (response.IsSuccessStatusCode) { var data = response.Content.ReadAsStringAsync().Result; ViewModel.ResponseModel.ResponseViewModel <Dictionary <string, bool> > dbBookingDetails = JsonConvert.DeserializeObject <ViewModel.ResponseModel.ResponseViewModel <Dictionary <string, bool> > >(data); if (dbBookingDetails.IdentityResult.Status == true) { return(Json(new { code = 0, message = "Success" })); } else { if (dbBookingDetails.IdentityResult.Message == "Invalid access details, Please log-out.") { return(Json(new { code = -99, message = "Please Login Again" })); } else { return(Json(new { code = -1, message = dbBookingDetails.IdentityResult.Message })); } } } else { return(Json(new { code = -2, message = "failed" })); } }
public IActionResult Create(CreateSlotModel model) { // TODO : learn how to validate model in pop up if (ModelState.IsValid) { SlotViewModel slot = new SlotViewModel() { IsBooked = false, ParkingLotId = model.ParkingLotId, SlotTypeId = model.SlotTypeId, HourlyRate = model.HourlyRate }; ResponseDetails response = _apiHelper.SendApiRequest(slot, "slot/add", HttpMethod.Post); if (response.Success) { return(RedirectToAction("Manage", new { Id = _dataProtector.Protect(model.ParkingLotId) })); } else { ErrorViewModel errorModel = new ErrorViewModel { Message = response.Data.ToString() }; return(View("Error", errorModel)); } } return(RedirectToAction("Manage", new { Id = _dataProtector.Protect(model.ParkingLotId) })); }
// GET: Slot/Create public ActionResult Create() { SlotViewModel slotViewModel = new SlotViewModel() { LocationsAvailable = GetLocations() }; return(View(slotViewModel)); }
public ActionResult Edit(SlotViewModel slotViewModel) { if (ModelState.IsValid) { _repository.SlotSaveChanges(slotViewModel.SlotDetail); return(RedirectToAction("Index")); } return(View(slotViewModel)); }
private SlotViewModel MapSlot(Slot model) { SlotViewModel modelMapping = _mapper.Map <SlotViewModel> (model); modelMapping.SlotTypeViewModel = _mapper.Map <SlotTypeViewModel> (model.SlotType); modelMapping.ParkingLotViewModel = _mapper.Map <ParkingLotViewModel> (model.ParkingLot); return(modelMapping); }
public IActionResult Post([FromBody] SlotViewModel slot) { if (ModelState.IsValid) { _slotServ.AddSlot(slot); return(Ok(slot)); } return(HttpBadRequest(ModelState)); }
public void AddSlot(ref SlotViewModel slot) { if (!usedSlot.Contains(slot)) { usedSlot.Add(slot); slot.IsSelected = !slot.IsSelected; CheckedRule(); } }
public void DeleteSlot(ref SlotViewModel slot) { if (usedSlot.Contains(slot)) { slot.IsSelected = !slot.IsSelected; usedSlot.Remove(slot); CheckedRule(); } }
public ActionResult Create(SlotViewModel slotViewModel) { if (ModelState.IsValid) { _repository.CreateSlot(slotViewModel.SlotDetail); return(RedirectToAction("Index")); } return(View(slotViewModel)); }
public SlotViewModel MapSlot(Slot model) { SlotViewModel modelMapping = _mapper.Map <SlotViewModel> (model); modelMapping.BookingViewModels = MapBookings(model.Bookings); modelMapping.SlotTypeViewModel = _mapper.Map <SlotTypeViewModel> (model.SlotType); modelMapping.ParkingLotViewModel = _mapper.Map <ParkingLotViewModel> (model.ParkingLot); return(modelMapping); }
/// <summary> /// Delete PopUp For Time Slot /// </summary> /// <param name="slotId"> Id Of Slot</param> /// <returns> Return Details Of PopUp In String Format</returns> public JsonResult DeletePopUp(long slotId) { SlotViewModel slotViewModel = new SlotViewModel() { SlotId = slotId }; string convertedData = Common.HtmlHelper.RenderViewToString(this.ControllerContext, "~/Views/TimeSlotDetail/_Delete.cshtml", slotViewModel); return(Json(new { code = 0, message = convertedData })); }
public object Update(SlotViewModel model) { bool success = _slotService.Update(model); if (success) { return(new ResponseDetails(true, "parking slot updated successfully.")); } return(new ResponseDetails(false, $"Parking Slot with Id : { model.Id } does not exists.")); }
public object Get(int id) { SlotViewModel model = _slotService.Get(id); if (model == null) { return(new ResponseDetails(false, $"Parking Slot with Id : { id } does not exists.")); } return(new ResponseDetails(true, model)); }
public object Add(SlotViewModel model) { model = _slotService.Add(model); if (model == null) { return(new ResponseDetails(false, "Could not add slot.")); } return(new ResponseDetails(true, model)); }
public IActionResult Post(int id, [FromBody] SlotViewModel slot) { if (slot == null) { throw new Exception("Could not find slot with id " + id); } //Wendy - NEED TO MAKE SURE Admins can add new rooms _slotServ.UpdateSlot(id, slot); return(Ok()); }
// Add a new slot public void AddSlot(SlotViewModel slot) { var newSlot = new Slot { PresentationId = slot.PresentationId, SpeakerId = slot.SpeakerId, RoomId = slot.RoomId, StartTime = slot.StartTime, EndTime = slot.EndTime }; _slotRepo.AddSlot(newSlot); _slotRepo.SaveChanges(); }
public bool Update(SlotViewModel model) { if (_unitOfWork.SlotRepository.SlotExists(model.Id)) { Slot modelMapping = _mapper.Map <Slot> (model); _unitOfWork.SlotRepository.Update(modelMapping); _unitOfWork.SaveChanges(); return(true); } return(false); }
public SlotViewModel Add(SlotViewModel model) { Slot modelMapping = _mapper.Map <Slot> (model); modelMapping = _unitOfWork.SlotRepository.Add(modelMapping); if (modelMapping != null) { _unitOfWork.SaveChanges(); return(Get(modelMapping.Id)); } return(null); }
public object MakeBooked(int id) { SlotViewModel model = _slotService.Get(id); if (model == null) { return(new ResponseDetails(false, $"Parking Slot with Id : { id.ToString () } does not exists.")); } model.IsBooked = true; _slotService.Update(model); return(new ResponseDetails(true, "parking slot is now marked as booked.")); }
private List <SlotViewModel> MapSlots(List <Slot> model) { List <SlotViewModel> modelMapping = new List <SlotViewModel> (); for (int i = 0; i < model.Count; i++) { SlotViewModel slot = _mapper.Map <SlotViewModel> (model[i]); slot.SlotTypeViewModel = _mapper.Map <SlotTypeViewModel> (model[i].SlotType); slot.BookingViewModels = _mapper.Map <List <BookingViewModel> > (model[i].Bookings); modelMapping.Add(slot); } return(modelMapping); }
// This is an Edit of a specific slot public void UpdateSlot(int slotId, SlotViewModel slot) { var editedSlot = _slotRepo.GetById(slotId).FirstOrDefault(); if (editedSlot == null) { throw new Exception("Could not find slot with id " + slotId); } editedSlot.PresentationId = slot.PresentationId; editedSlot.SpeakerId = slot.SpeakerId; editedSlot.RoomId = slot.RoomId; editedSlot.StartTime = slot.StartTime; editedSlot.EndTime = slot.EndTime; _slotRepo.SaveChanges(); }
// GET: Slot/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Slot slot = _repository.GetSlotById(id); if (slot == null) { return(HttpNotFound()); } SlotViewModel slotVm = new SlotViewModel(); slotVm.SlotDetail = slot; slotVm.LocationName = _repository.GetLocationById(slot.LocationId).Name; return(View(slotVm)); }
private bool CanBookSlot(SlotViewModel model) { if (model.IsBooked) { BookingViewModel bookingInfo = model.BookingViewModels.FirstOrDefault(x => x.IsActive); if (bookingInfo != null) { if ((bookingInfo.StartDateTime - DateTime.Now).TotalMinutes <= 60) { return(false); } } return(false); } return(true); }
// GET: Slot/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Slot slot = _repository.GetSlotById(id); if (slot == null) { return(HttpNotFound()); } SlotViewModel slotViewModel = new SlotViewModel() { SlotDetail = slot, LocationIdString = slot.LocationId.ToString(), LocationsAvailable = GetLocations() }; return(View(slotViewModel)); }
public IActionResult ChangeHourlyRate(SlotViewModel model) { if (ModelState.IsValid) { ResponseDetails response = _apiHelper.SendApiRequest(model, "slot/update", HttpMethod.Post); if (response.Success) { return(RedirectToAction("Details", new { Id = _dataProtector.Protect(model.Id) })); } else { ErrorViewModel errorModel = new ErrorViewModel() { Message = response.Data.ToString() }; return(View("Error", errorModel)); } } return(RedirectToAction("Details", new { Id = _dataProtector.Protect(model.Id) })); }