private bool ValidateDate(String date)
 {
     try
     {
         FacilityUtil.ConvertDateStringFromCalendarToDateTime(date);
     }
     catch (Exception e)
     {
         return(false);
     }
     return(true);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string dateString = FacilityUtil.ConvertDateTimeToDateStringCalendar(DateTime.Now);
         TextBoxSearchBooking.Text = dateString;
         LoadTable(dateString);
     }
     else
     {
         LoadTable(TextBoxSearchBooking.Text);
     }
 }
        private bool validateTimes()
        {
            string startTime        = DropDownListStartTime.SelectedValue;
            string startTimeMinutes = DropDownListStartMinutes.SelectedValue;
            string startTimePeriod  = DropDownListStartPeriod.SelectedValue;

            DateTime starting = FacilityUtil.ConvertDateTime(startTime, startTimeMinutes, startTimePeriod);

            string endTime        = DropDownListEndTime.SelectedValue;
            string endTimeMinutes = DropDownListEndMinutes.SelectedValue;
            string endTimePeriod  = DropDownListEndDayPeriod.SelectedValue;

            DateTime ending = FacilityUtil.ConvertDateTime(endTime, endTimeMinutes, endTimePeriod);

            return(starting.CompareTo(ending) < 0);
        }
Example #4
0
        public IActionResult Get()
        {
            var ret = (dynamic)null;

            try
            {
                ret = FacilityUtil.GetFacility();
                return(Ok(new { result = ret }));
            }
            catch (Exception ex)
            {
                //status.Code = ResCode.SYSTEM_ERROR;
                //status.Desc = $"{ResDesc.SYSTEM_ERROR} --> {ex.Message}";
                //ret.Status = status;
                logger.Log(LogLevel.Error, $"[FacilityController][Get] {ex.Message}|{ex.InnerException?.Message}|{ex.InnerException?.InnerException?.Message}");
                return(Unauthorized(new { result = ret }));
            }
        }
        public void CustomValidator_ValidateTimes(object source, ServerValidateEventArgs args)
        {
            string startTime        = DropDownListStartTime.SelectedValue;
            string startTimeMinutes = DropDownListStartMinutes.SelectedValue;
            string startTimePeriod  = DropDownListStartPeriod.SelectedValue;

            DateTime starting = FacilityUtil.ConvertDateTime(startTime, startTimeMinutes, startTimePeriod);

            string endTime        = DropDownListEndTime.SelectedValue;
            string endTimeMinutes = DropDownListEndMinutes.SelectedValue;
            string endTimePeriod  = DropDownListEndDayPeriod.SelectedValue;

            DateTime ending = FacilityUtil.ConvertDateTime(endTime, endTimeMinutes, endTimePeriod);

            if (!validateTimes())
            {
                args.IsValid = false;
            }
        }
        private Facility buildFacility()
        {
            string name     = textboxFacityName.Text;
            string timeSlot = DropDownListTimeSlot.SelectedValue;
            int    slot     = Int16.Parse(timeSlot);

            string startTime        = DropDownListStartTime.SelectedValue;
            string startTimeMinutes = DropDownListStartMinutes.SelectedValue;
            string startTimePeriod  = DropDownListStartPeriod.SelectedValue;

            DateTime starting = FacilityUtil.ConvertDateTime(startTime, startTimeMinutes, startTimePeriod);

            string endTime        = DropDownListEndTime.SelectedValue;
            string endTimeMinutes = DropDownListEndMinutes.SelectedValue;
            string endTimePeriod  = DropDownListEndDayPeriod.SelectedValue;

            DateTime ending = FacilityUtil.ConvertDateTime(endTime, endTimeMinutes, endTimePeriod);

            return(new Facility(name, slot, starting, ending));
        }
        public FacilityQuery()
        {
            Field <ListGraphType <FacilityType> >(
                name: "facilitys",
                description: "get all facilities",
                resolve: context => FacilityUtil.GetFacility());

            FieldAsync <FacilityType>(
                name: "facility",
                description: "get facility by id",
                arguments: new QueryArguments(new QueryArgument <IdGraphType> {
                Name = "id"
            }),
                resolve: async context =>
            {
                var id    = context.GetArgument <string>("id");
                var model = await FacilityUtil.FacilityByIdAsync(id);
                return(model);
            });
        }
        private void LoadTable()
        {
            HttpCookie userCookie;
            int        user_id = -1;

            userCookie = Request.Cookies["UserID"];
            if (userCookie != null)
            {
                user_id = Convert.ToInt32(userCookie.Value);
            }
            List <Booking> bookings = BookingController.GetInstance().SearchBooking(user_id,
                                                                                    DateTime.Now,
                                                                                    DateTime.Now.AddDays(7));

            //show or not the table
            table.Visible      = bookings.Count > 0;
            NoElements.Visible = bookings.Count < 1;
            DashboardTable.Rows.Clear();

            TableRow row0 = new TableRow();

            row0.BackColor = System.Drawing.Color.FromArgb(255, 106, 169, 80);
            TableCell cell01 = new TableCell();

            cell01.Text      = "Facility";
            cell01.Font.Bold = true;
            row0.Cells.Add(cell01);

            TableCell cell02 = new TableCell();

            cell02.Text      = "User";
            cell02.Font.Bold = true;
            row0.Cells.Add(cell02);

            TableCell cell05 = new TableCell();

            cell05.Text      = "Date";
            cell05.Font.Bold = true;
            row0.Cells.Add(cell05);

            TableCell cell03 = new TableCell();

            cell03.Text      = "Time Start";
            cell03.Font.Bold = true;
            row0.Cells.Add(cell03);

            TableCell cell04 = new TableCell();

            cell04.Text      = "Code Status";
            cell04.Font.Bold = true;
            row0.Cells.Add(cell04);

            DashboardTable.Rows.Add(row0);

            foreach (Booking b in bookings)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                cell1.Text = FacilityController.GetInstance().GetFacilityName(b.facility_id);
                row.Cells.Add(cell1);

                TableCell cell2 = new TableCell();
                cell2.Text = UserController.GetInstance().GetUserName(b.user_id);
                row.Cells.Add(cell2);

                TableCell cell15 = new TableCell();
                cell15.Text = FacilityUtil.ConvertDateTimeToDateString(b.date);
                row.Cells.Add(cell15);

                TableCell cell3 = new TableCell();
                cell3.Text = b.time_start.ToString();
                row.Cells.Add(cell3);

                String    status = AccessCodeController.GetInstance().RetrieveStatus(b.user_id, b.booking_id).ToString();
                TableCell cell4  = new TableCell();
                cell4.Text = status;
                row.Cells.Add(cell4);

                DashboardTable.Rows.Add(row);
            }
        }
        private void LoadTable(String search)
        {
            //string search = TextBoxSearchFacility.Text;
            List <Booking> bookings = BookingController.GetInstance().SearchBooking(FacilityUtil.ConvertDateStringFromCalendarToDateTime(search));

            //show or not the table
            tableBookings.Visible     = bookings.Count > 0;
            NoBookingElements.Visible = bookings.Count < 1;
            BookingsTable.Rows.Clear();

            TableRow row0 = new TableRow();

            row0.BackColor = System.Drawing.Color.FromArgb(255, 106, 169, 80);
            TableCell cell01 = new TableCell();

            cell01.Text      = "Facility";
            cell01.Font.Bold = true;
            row0.Cells.Add(cell01);

            TableCell cell02 = new TableCell();

            cell02.Text      = "User";
            cell02.Font.Bold = true;
            row0.Cells.Add(cell02);

            TableCell cell03 = new TableCell();

            cell03.Text      = "Time Start";
            cell03.Font.Bold = true;
            row0.Cells.Add(cell03);

            TableCell cell04 = new TableCell();

            cell04.Text      = "Code Status";
            cell04.Font.Bold = true;
            row0.Cells.Add(cell04);

            TableCell cell05 = new TableCell();

            cell05.Text      = " ";
            cell05.Font.Bold = true;
            row0.Cells.Add(cell05);

            /*
             * TableCell cell06 = new TableCell();
             * cell06.Text = " ";
             * cell06.Font.Bold = true;
             * row0.Cells.Add(cell06);*/

            BookingsTable.Rows.Add(row0);

            foreach (Booking b in bookings)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                cell1.Text = FacilityController.GetInstance().GetFacilityName(b.facility_id);
                row.Cells.Add(cell1);

                TableCell cell2 = new TableCell();
                cell2.Text = UserController.GetInstance().GetUserName(b.user_id);
                row.Cells.Add(cell2);

                TableCell cell3 = new TableCell();
                cell3.Text = b.time_start.ToString();
                row.Cells.Add(cell3);

                String    status = AccessCodeController.GetInstance().RetrieveStatus(b.user_id, b.booking_id).ToString();
                TableCell cell4  = new TableCell();
                cell4.Text = status;
                row.Cells.Add(cell4);

                TableCell cell5 = new TableCell();
                if (AccessCode.ConvertStatus(status) == AccessCode.Status.Validated)
                {
                    Button buttonEndAccess = new Button();
                    buttonEndAccess.Text            = "End Access";
                    buttonEndAccess.CommandArgument = b.booking_id.ToString();
                    buttonEndAccess.CssClass        = "w3-button w3-black w3-padding w3-small w3-round";
                    buttonEndAccess.Attributes.Add("autopostback", "false");
                    buttonEndAccess.Click += End_Access_Click;
                    cell5.Controls.Add(buttonEndAccess);
                }
                else if (AccessCode.ConvertStatus(status) == AccessCode.Status.Ended)
                {
                    cell5.Text = " ";
                }
                else
                {
                    Button buttonValidateAccess = new Button();
                    buttonValidateAccess.Text            = "Validate Access Code";
                    buttonValidateAccess.CommandArgument = b.booking_id.ToString();
                    buttonValidateAccess.CssClass        = "w3-button w3-black w3-padding w3-small w3-round";
                    buttonValidateAccess.Attributes.Add("autopostback", "false");
                    buttonValidateAccess.Click += Validate_Click;
                    cell5.Controls.Add(buttonValidateAccess);
                }
                row.Cells.Add(cell5);

                /*
                 * TableCell cell6 = new TableCell();
                 * Button buttonDelete = new Button();
                 * buttonDelete.Text = "Delete";
                 * buttonDelete.CommandArgument = b.booking_id.ToString();
                 * buttonDelete.CssClass = "w3-button w3-black w3-padding w3-small w3-round";
                 * buttonDelete.Attributes.Add("autopostback", "false");
                 * buttonDelete.Click += Delete_Click;
                 * cell6.Controls.Add(buttonDelete);
                 * row.Cells.Add(cell6);*/
                BookingsTable.Rows.Add(row);
            }
        }
Example #10
0
        private void LoadTable(String date)
        {
            List <Booking> bookings = BookingController.GetInstance().SearchBooking(FacilityUtil.ConvertDateStringFromCalendarToDateTime(date));

            //show or not the table
            table.Visible      = bookings.Count > 0;
            NoElements.Visible = bookings.Count < 1;
            DashboardTable.Rows.Clear();

            TableRow row0 = new TableRow();

            row0.BackColor = System.Drawing.Color.FromArgb(255, 106, 169, 80);
            TableCell cell01 = new TableCell();

            cell01.Text      = "Facility";
            cell01.Font.Bold = true;
            row0.Cells.Add(cell01);

            TableCell cell02 = new TableCell();

            cell02.Text      = "User";
            cell02.Font.Bold = true;
            row0.Cells.Add(cell02);

            TableCell cell03 = new TableCell();

            cell03.Text      = "Time Start";
            cell03.Font.Bold = true;
            row0.Cells.Add(cell03);

            TableCell cell04 = new TableCell();

            cell04.Text      = "Code Status";
            cell04.Font.Bold = true;
            row0.Cells.Add(cell04);

            DashboardTable.Rows.Add(row0);

            foreach (Booking b in bookings)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                cell1.Text = FacilityController.GetInstance().GetFacilityName(b.facility_id);
                row.Cells.Add(cell1);

                TableCell cell2 = new TableCell();
                cell2.Text = UserController.GetInstance().GetUserName(b.user_id);
                row.Cells.Add(cell2);

                TableCell cell3 = new TableCell();
                cell3.Text = b.time_start.ToString();
                row.Cells.Add(cell3);

                String    status = AccessCodeController.GetInstance().RetrieveStatus(b.user_id, b.booking_id).ToString();
                TableCell cell4  = new TableCell();
                cell4.Text = status;
                row.Cells.Add(cell4);

                DashboardTable.Rows.Add(row);
            }
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string dateString = FacilityUtil.ConvertDateTimeToDateStringCalendar(DateTime.Now);

            LoadTable(dateString);
        }
Example #12
0
        public void UpdateFacility(Facility Facility)
        {
            SqlParameter[] parameters = new SqlParameter[4];
            parameters[0] = new SqlParameter()
            {
                ParameterName = "@name", SqlDbType = System.Data.SqlDbType.NChar, Value = Facility.Name
            };
            parameters[1] = new SqlParameter()
            {
                ParameterName = "@time_slot_length", SqlDbType = System.Data.SqlDbType.NChar, Value = Facility.timeSlot
            };
            parameters[2] = new SqlParameter()
            {
                ParameterName = "@day_start_time", SqlDbType = System.Data.SqlDbType.Time, Value = FacilityUtil.ConvertDateTimeToTimeString(Facility.StartTime)
            };
            parameters[3] = new SqlParameter()
            {
                ParameterName = "@day_end_time", SqlDbType = System.Data.SqlDbType.Time, Value = FacilityUtil.ConvertDateTimeToTimeString(Facility.EndTime)
            };

            UpdateUsingTransaction(parameters, Facility.Id);
        }
Example #13
0
 public override Object CreateObject(SqlDataReader reader)
 {
     return(new Facility((int)reader["facility_id"], (string)reader["name"],
                         (int)reader["time_slot_length"], FacilityUtil.ConvertTimeStringToDateTime(((TimeSpan)reader["day_start_time"]).ToString()),
                         FacilityUtil.ConvertTimeStringToDateTime(((TimeSpan)reader["day_end_time"]).ToString())));
 }