public object BindModel(
                ControllerContext controllerContext,
                ModelBindingContext bindingContext,
                MemberDescriptor memberDescriptor)
            {
                List<RoomReservation_StatusViewModel> res = new List<RoomReservation_StatusViewModel>();
                var form = controllerContext.HttpContext.Request.Form;
                int i = 0;

                while (!string.IsNullOrEmpty(form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.ReservationStatusTypeId"]))
                {
                    var model = new RoomReservation_StatusViewModel();
                    var ReservationStatusType = new ReservationStatusType();
                    var RoomReservation_Status = new RoomReservation_Status();

                    if (form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.Id"] != "")
                        RoomReservation_Status.Id = int.Parse(form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.Id"]);


                    if (form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.RoomReservation_Id"] !="")                   
                        RoomReservation_Status.RoomReservation_Id = int.Parse(form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.RoomReservation_Id"]);

                    if (form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.Reservation_StatusDate"] != "")
                        RoomReservation_Status.Reservation_StatusDate = DateTime.Parse(form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.Reservation_StatusDate"]);


                    RoomReservation_Status.ReservationStatusTypeId = int.Parse(form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.ReservationStatusTypeId"]);
                    ReservationStatusType.Name = form["RoomReservation_StatusViewModel[" + i + "].ReservationStatusType.Name"];
                    if (!string.IsNullOrEmpty(form["RoomReservation_StatusViewModel[" + i + "].ReservationStatusType.RoomStatusTypeId"]))
                    ReservationStatusType.RoomStatusTypeId =int.Parse ( form["RoomReservation_StatusViewModel[" + i + "].ReservationStatusType.RoomStatusTypeId"]);
                    if (!string.IsNullOrEmpty(form["RoomReservation_StatusViewModel[" + i + "].Reason_TypeId"]))
                        RoomReservation_Status.Reason_TypeId = int.Parse(form["RoomReservation_StatusViewModel[" + i + "].Reason_TypeId"]);
                    RoomReservation_Status.Notes =  form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.Notes"];
                    ReservationStatusType.Id = int.Parse(form["RoomReservation_StatusViewModel[" + i + "].RoomReservation_Status.ReservationStatusTypeId"]);
                    


                    model.ReservationStatusType = ReservationStatusType;
                    model.RoomReservation_Status = RoomReservation_Status;
                    

                    res.Add(model);
                    i++;
                }

                return res;
             
        }
          public async Task<List<RoomReservation_StatusViewModel>> FillStatus(RoomReservation_Status  db_status=null, long reservation_id=0 )
          {
              var list = new List<RoomReservation_StatusViewModel>();
              IEnumerable<ReservationStatusType> statuslist;
              bool isShowdb_status = false;
              if (db_status!=null)
              {

                  if (! string.IsNullOrEmpty (db_status.ReservationStatusType.Next_Status))
                  {
                      string[] next_status = db_status.ReservationStatusType.Next_Status.Split(',');
                      statuslist = await _ReservationStatusTypeRepository.GetAllEnabledbyIds(next_status);
                      statuslist = statuslist.OrderByDescending(s => s.Id);
                  }
                  else
                  {
                      isShowdb_status = true;
                      statuslist = new List<ReservationStatusType> { db_status.ReservationStatusType };
                  }

              }
              else
              {
                  statuslist = await _ReservationStatusTypeRepository.GetAllEnabled();
                 statuslist= statuslist.Where(s => s.IsDefault.Value).OrderByDescending(s => s.Id);

              }

             
             
              foreach (var status in statuslist)
              {
                  RoomReservation_Status  roomreservation_status;
                  if (isShowdb_status)
                    roomreservation_status =db_status;
                  else

                    roomreservation_status = new RoomReservation_Status();

                  RoomReservation_StatusViewModel roomreservation_statusviewmodel=new RoomReservation_StatusViewModel();
                 
                  roomreservation_statusviewmodel.RoomReservation_Status = roomreservation_status;
                  roomreservation_statusviewmodel.RoomReservation_Status.ReservationStatusTypeId = status.Id;
                  if (status.Name == RoomReservationSystem.Model.Enums.eReservationStatusType.Cancelled.ToString())
                  { // Things to do: create listtype webapi, and repository, listtype and reasons interface does not exists.
                      // var listType = await _ListTypesRepository.GetByName(RoomReservationSystem.Model.Enums.ListType.RoomReservation_CancelationReasons.ToString());

                      var cancellation_reasons = await _Reason_TypesRepository.GetbyListTypeId(((int)RoomReservationSystem.Model.Enums.ListType.RoomReservation_CancelationReasons).ToString());
                      var cancellation_reasons_selectlist = new SelectList(cancellation_reasons, "Id", "Name", roomreservation_status.Reason_TypeId).ToList();
                      cancellation_reasons_selectlist.Insert(0, new SelectListItem() { Text = "Select Reason", Value = "0" });
                      ViewBag.Reason_TypeId = cancellation_reasons_selectlist;
                  }
                  
                  roomreservation_statusviewmodel.ReservationStatusType = status;
                   
                
                  list.Add(roomreservation_statusviewmodel);
               
              }

              if (statuslist.Count()>0)

                statuslist.First().IsDefault  = true;  
              return list;


          }