示例#1
0
        public void UpdateFacility_RegularValues_OkResults()
        {
            //Arrange
            var facility = new Mock <IFacility>();

            facility.SetupGet(a => a.Id).Returns(4);
            facility.SetupGet(a => a.BuildingId).Returns(1);
            facility.SetupGet(a => a.Level).Returns(model.Level);
            facility.SetupGet(a => a.Number).Returns(model.Number);

            facade.Setup(f => f.UpdateFacility("3445", model.Id, model.Level, model.Number)).Returns(facility.Object);

            var controller = new FacilityController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.UpdateFacility(model);

            //Assert
            Assert.NotNull(result);

            var okresult = Assert.IsType <OkNegotiatedContentResult <GenericResponse> >(result);

            Assert.Equal(true, okresult.Content.IsSuccess);
        }
        public FacilityControllerTests()
        {
            mediator = A.Fake<IMediator>();

            A.CallTo(() => mediator.SendAsync(A<GetCountries>._)).Returns(new List<CountryData>
            {
                new CountryData
                {
                    Id = new Guid("4345FB05-F7DF-4E16-939C-C09FCA5C7D7B"),
                    Name = "United Kingdom"
                },
                new CountryData
                {
                    Id = new Guid("29B0D09E-BA77-49FB-AF95-4171408C07C9"),
                    Name = "Germany"
                }
            });

            A.CallTo(
                () =>
                    mediator.SendAsync(A<GetNotificationBasicInfo>.That.Matches(p => p.NotificationId == notificationId)))
                .Returns(new NotificationBasicInfo
                {
                    CompetentAuthority = UKCompetentAuthority.England,
                    NotificationId = notificationId,
                    NotificationNumber = "GB 0001 002000",
                    NotificationType = NotificationType.Recovery
                });

            facilityController = new FacilityController(mediator, new AddAddressBookEntryMap());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["facultyId"] != null)
                {
                    int      id       = Int16.Parse((string)Session["facultyId"]);
                    Facility facility = FacilityController.GetInstance().Recover(id);
                    HiddenFieldFacilityId.Value = facility.Id.ToString();


                    textboxFacityName.Text             = facility.Name;
                    DropDownListTimeSlot.SelectedValue = facility.timeSlot.ToString();


                    DropDownListStartTime.SelectedValue    = Int16.Parse(facility.StartTime.ToString("hh", CultureInfo.InvariantCulture)).ToString();
                    DropDownListStartMinutes.SelectedValue = Int16.Parse(facility.StartTime.ToString("mm", CultureInfo.InvariantCulture)).ToString();
                    DropDownListStartPeriod.SelectedValue  = facility.StartTime.ToString("tt", CultureInfo.InvariantCulture);

                    DropDownListEndTime.SelectedValue      = Int16.Parse(facility.EndTime.ToString("hh", CultureInfo.InvariantCulture)).ToString();
                    DropDownListEndMinutes.SelectedValue   = Int16.Parse(facility.EndTime.ToString("mm", CultureInfo.InvariantCulture)).ToString();
                    DropDownListEndDayPeriod.SelectedValue = facility.EndTime.ToString("tt", CultureInfo.InvariantCulture);

                    buttonCreateFacility.Visible = false;
                    add.Visible = false;
                }
                else
                {
                    buttonUpdateFacility.Visible = false;
                    edit.Visible = false;
                }
            }
        }
        private void Delete_Click(object sender, System.EventArgs args)
        {
            string id = ((Button)sender).CommandArgument;

            FacilityController.GetInstance().DeleteFacility(Int16.Parse(id));
            Response.Redirect("~/Pages/Facilities/Facilities.aspx");
        }
        public void FetchFacility_RegularValues_OkResults()
        {
            //Arrange
            var bm = new Mock <IFacility>();

            bm.SetupGet(a => a.Id).Returns(2);

            facade.Setup(f => f.FetchFacility("3445", 2)).Returns(bm.Object);

            var controller = new FacilityController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.FetchFacility(2);

            //Assert
            Assert.NotNull(result);

            var okresult = Assert.IsType <OkNegotiatedContentResult <IFacility> >(result);

            Assert.NotNull(okresult.Content);
            Assert.Equal(2, okresult.Content.Id);
        }
示例#6
0
        public void InsertUpdateDelete()
        {
            FacilityController facilityController = new FacilityController();

            //create new entity
            Facility facility = new Facility();

            facility.facilityId   = Guid.NewGuid();
            facility.name         = "Test Name";
            facility.entryDate    = DateTime.Now;
            facility.appUserId    = Guid.NewGuid();
            facility.modifiedDate = DateTime.Now;
            facility.remark       = "Test Remark";

            //insert
            var result1 = facilityController.Post(facility);
            //update
            var result2 = facilityController.Post(facility);
            //delete
            var result3 = facilityController.Delete(facility.facilityId);

            //assert
            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);
            Assert.IsNotNull(result3);
            Assert.IsTrue(result1 is OkResult);
            Assert.IsTrue(result2 is OkResult);
            Assert.IsTrue(result3 is OkResult);
        }
示例#7
0
        public FacilityControllerTests()
        {
            mediator          = A.Fake <IMediator>();
            this.auditService = A.Fake <IAuditService>();

            A.CallTo(() => mediator.SendAsync(A <GetCountries> ._)).Returns(new List <CountryData>
            {
                new CountryData
                {
                    Id   = new Guid("4345FB05-F7DF-4E16-939C-C09FCA5C7D7B"),
                    Name = "United Kingdom"
                },
                new CountryData
                {
                    Id   = new Guid("29B0D09E-BA77-49FB-AF95-4171408C07C9"),
                    Name = "Germany"
                }
            });

            A.CallTo(
                () =>
                mediator.SendAsync(A <GetNotificationBasicInfo> .That.Matches(p => p.NotificationId == notificationId)))
            .Returns(new NotificationBasicInfo
            {
                CompetentAuthority = UKCompetentAuthority.England,
                NotificationId     = notificationId,
                NotificationNumber = "GB 0001 002000",
                NotificationType   = NotificationType.Recovery
            });

            facilityController = new FacilityController(mediator, new AddAddressBookEntryMap(), this.auditService);

            A.CallTo(() => auditService.AddAuditEntry(this.mediator, notificationId, "user", NotificationAuditType.Added, NotificationAuditScreenType.RecoveryFacilities));
        }
示例#8
0
        public void Get()
        {
            FacilityController facilityController = new FacilityController();

            Facility[] cities = facilityController.Get().ToArray();

            Assert.IsNotNull(cities);
        }
 protected void buttonCreateFacility_Click(object sender, EventArgs e)
 {
     if (validateTimes())
     {
         FacilityController.GetInstance().InsertFacility(buildFacility());
         Response.Redirect("~/Pages/Facilities/Facilities.aspx");
     }
 }
示例#10
0
        public void GetTest()
        {
            var controller    = new FacilityController(fixture.Service);
            var result        = controller.Get();
            var contentResult = result as OkNegotiatedContentResult <IEnumerable <R5AppFacilityInfo> >;

            Assert.NotNull(contentResult);
            Assert.Equal(2, contentResult.Content.Count());
        }
示例#11
0
 public void BindGrid()
 {
     try
     {
         lstServices.DataSource = FacilityController.GetFacilities();
         lstServices.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void buttonUpdateFacility_Click(object sender, EventArgs e)
        {
            if (validateTimes())
            {
                Facility facility = buildFacility();
                facility.Id = Int16.Parse(HiddenFieldFacilityId.Value);
                FacilityController.GetInstance().UpdateFacility(facility);

                Session.Remove("facultyId");
                Response.Redirect("~/Pages/Facilities/Facilities.aspx");
            }
        }
 public void BindGrid()
 {
     try
     {
         grdFacillity.DataSource = FacilityController.GetFacilities();
         grdFacillity.DataBind();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#14
0
 public void BindFacilities()
 {
     try
     {
         lvServices.DataSource = lvServiceSlide.DataSource = FacilityController.GetFacilities();
         lvServiceSlide.DataBind();
         lvServices.DataBind();
         ProvideClass();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void BindValues()
 {
     try
     {
         Facility objFaciliy = FacilityController.GetFacilitiesById(FacilityId);
         txtDescp.Text   = objFaciliy.description;
         txtName.Text    = objFaciliy.facilityName;
         serImg.ImageUrl = objFaciliy.image;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void FetchFacilities_RegularValues_OkResults()
        {
            //Arrange
            var bm = new Mock <IFacility>();

            bm.SetupGet(a => a.Id).Returns(2);

            var bmNew = new Mock <IFacility>();

            bmNew.SetupGet(a => a.Id).Returns(3);

            var bmList = new List <IFacility>()
            {
                bm.Object, bmNew.Object
            };

            facade.Setup(f => f.FetchFacilities("3445")).Returns(bmList);

            var controller = new FacilityController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.FetchFacilities();

            //Assert
            Assert.NotNull(result);

            var okresult = Assert.IsType <OkNegotiatedContentResult <IEnumerable <IFacility> > >(result);

            Assert.NotNull(okresult.Content);
            Assert.Equal(2, okresult.Content.Count());

            var enumerator = okresult.Content.GetEnumerator();

            enumerator.MoveNext();
            Assert.NotNull(enumerator.Current);
            Assert.Equal(2, enumerator.Current.Id);

            enumerator.MoveNext();
            Assert.NotNull(enumerator.Current);
            Assert.Equal(3, enumerator.Current.Id);

            enumerator.Dispose();
        }
示例#17
0
        public void UpdateFacility_ThrowsError_BadModel()
        {
            //Arrange
            var controller = new FacilityController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            controller.ModelState.AddModelError("Key", "ErrorMessage");

            //Act
            var result = controller.UpdateFacility(model);

            //Assert
            Assert.NotNull(result);
            Assert.IsType <InvalidModelStateResult>(result);
        }
        public void UpdateFacility()
        {
            try
            {
                try
                {
                    Facility objFaciliy = FacilityController.GetFacilitiesById(FacilityId);
                    objFaciliy.facilityName = txtName.Text;
                    objFaciliy.description  = txtDescp.Text;
                    if (fileUpldImg.HasFile)
                    {
                        string fileName = "", path = "", ext = "";

                        ext = Path.GetExtension(fileUpldImg.PostedFile.FileName);

                        if (ext.Equals(".jpg") || ext.Equals(".png") || ext.Equals(".gif") || ext.Equals(".jpeg"))
                        {
                            fileName = Path.GetFileName(fileUpldImg.PostedFile.FileName);
                            path     = "ServiceImages/" + fileName;
                            ResizeImage(fileUpldImg.PostedFile.InputStream, Server.MapPath(path));
                            //fileUpldImg.SaveAs(Server.MapPath(path));
                            objFaciliy.image = path;
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "err_msg", "MessageBox('Error','Please select Image file Only');", true);
                        }
                    }
                    objFaciliy = new FacilityController().UpdateFacility(objFaciliy);
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "suc_msg", "MessageBox('Success','Service Updated Successfully');", true);
                    ClearValues();
                    BindGrid();
                    PanelVisibility(true, false);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FacilityControllerUnitTests"/> class.
        /// </summary>
        public FacilityControllerUnitTests()
        {
            var mockLogger = new Mock <ILogger <FacilityController> >();

            _mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            _mockEventBus            = new Mock <IEventBus>();
            _mockFacilityManager     = new Mock <IFacilityManager>();
            var messageBusTopics = new Mock <IOptions <MessageBusTopics> >();

            _mockHttpContextAccessor.SetupGet(b => b.HttpContext.Request.Headers).Returns(new HeaderDictionary()
            {
                { "key1", "value1" }, { "key2", "value2" }
            });
            messageBusTopics.Setup(b => b.Value).Returns(() => new MessageBusTopics()
            {
                KafkaFacilityDetailsTopic = "busTopic"
            });
            _subject = new FacilityController(mockLogger.Object, _mockEventBus.Object,
                                              _mockFacilityManager.Object, messageBusTopics.Object, _mockHttpContextAccessor.Object);
        }
        public void FetchFacilities_ThrowsError_InternalError()
        {
            //Arrange
            var exception = new ConnApsDomain.Exceptions.InternalException();

            facade.Setup(f => f.FetchFacilities("3445")).Throws(exception);

            var controller = new FacilityController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.FetchFacilities();

            //Assert
            Assert.NotNull(result);

            Assert.IsType <InternalServerErrorResult>(result);
        }
示例#21
0
        public void UpdateFacility_ThrowsError_InternalError()
        {
            //Arrange
            var exception = new ConnApsDomain.Exceptions.InternalException();

            facade.Setup(f => f.UpdateFacility("3445", model.Id, model.Level, model.Number)).Throws(exception);

            var controller = new FacilityController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.UpdateFacility(model);

            //Assert
            Assert.NotNull(result);

            Assert.IsType <InternalServerErrorResult>(result);
        }
示例#22
0
        public FacilityControllerUnitTest()
        {
            var facilities = new List <Facility>
            {
                new Facility
                {
                    Id = 1
                }
            };
            var logger             = new Mock <ILogger <FacilityController> >();
            var facilityManagement = new Mock <IFacilityManagement>();

            facilityManagement.Setup(s => s.Create(It.IsAny <Facility>())).Returns((Facility f) =>
            {
                var maxId = facilities.Any() ? facilities.Max(m => m.Id) : 0;
                f.Id      = ++maxId;
                facilities.Add(f);
                return(f);
            });
            var mapper = new Mock <IMapper>();

            mapper.Setup(s => s.Map <FacilityIndexViewModel, Facility>(It.IsAny <FacilityIndexViewModel>())).Returns(
                (FacilityIndexViewModel m) => new Facility
            {
                CloseAt  = m.CloseAt,
                Id       = m.Id,
                Price    = m.Price,
                Name     = m.Name,
                OpensAt  = m.OpensAt,
                IsActive = m.IsActive
            });
            facilityController = new FacilityController(facilityManagement.Object, mapper.Object, logger.Object)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext {
                        User = TestHelper.GetAdminClaimsPrincipal()
                    }
                }
            };
        }
示例#23
0
        public void UpdateFacility_InvalidValues_BadRequest()
        {
            //Arrange
            var exception = new ConnApsDomain.Exceptions.NotFoundException("Facility");

            facade.Setup(f => f.UpdateFacility("3445", model.Id, model.Level, model.Number)).Throws(exception);

            var controller = new FacilityController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.UpdateFacility(model);

            //Assert
            Assert.NotNull(result);

            var badRequest = Assert.IsType <BadRequestErrorMessageResult>(result);

            Assert.Equal("The Facility you requested was not found. Please search again.", badRequest.Message);
        }
示例#24
0
 void Start()
 {
     c = transform.parent.GetComponent <FacilityController>();
 }
        private void LoadTable(String search)
        {
            //string search = TextBoxSearchFacility.Text;
            List <Facility> facilities = FacilityController.GetInstance().SearchFacility(search);

            //show or not the table
            tableFacilities.Visible    = facilities.Count > 0;
            NoFacilityElements.Visible = facilities.Count < 1;
            FacilitiesTable.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      = "Time Slot";
            cell02.Font.Bold = true;
            row0.Cells.Add(cell02);

            TableCell cell03 = new TableCell();

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

            TableCell cell04 = new TableCell();

            cell04.Text      = "End Time";
            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);
            FacilitiesTable.Rows.Add(row0);

            foreach (Facility f in facilities)
            {
                TableRow  row   = new TableRow();
                TableCell cell1 = new TableCell();
                cell1.Text = f.Name;
                row.Cells.Add(cell1);

                TableCell cell2 = new TableCell();
                cell2.Text = f.timeSlot + "";
                row.Cells.Add(cell2);

                TableCell cell3 = new TableCell();
                cell3.Text = f.StartTime.ToString("HH:mm tt");
                row.Cells.Add(cell3);

                TableCell cell4 = new TableCell();
                cell4.Text = f.EndTime.ToString("HH:mm tt");
                row.Cells.Add(cell4);
                FacilitiesTable.Rows.Add(row);

                TableCell cell5      = new TableCell();
                Button    buttonEdit = new Button();
                buttonEdit.Text            = "Edit";
                buttonEdit.CommandArgument = f.Id.ToString();
                buttonEdit.CssClass        = "w3-button w3-black w3-padding w3-small w3-round";
                buttonEdit.Attributes.Add("autopostback", "false");
                buttonEdit.Click += Edit_Click;
                cell5.Controls.Add(buttonEdit);
                row.Cells.Add(cell5);
                FacilitiesTable.Rows.Add(row);

                TableCell cell6        = new TableCell();
                Button    buttonDelete = new Button();
                buttonDelete.Text            = "Delete";
                buttonDelete.CommandArgument = f.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);
                FacilitiesTable.Rows.Add(row);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <string> dataRoles = new List <string>();

            dataRoles.Add(Core.Models.User.Category.Admin.ToString());
            dataRoles.Add(Core.Models.User.Category.Faculty.ToString());
            dataRoles.Add(Core.Models.User.Category.Moderator.ToString());
            dataRoles.Add(Core.Models.User.Category.Staff.ToString());
            dataRoles.Add(Core.Models.User.Category.Student.ToString());


            //show or not the table
            FacilityTable.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);

            foreach (string role in dataRoles)
            {
                TableCell cell02 = new TableCell();
                cell02.Text      = role;
                cell02.Font.Bold = true;
                row0.Cells.Add(cell02);
            }
            FacilityTable.Rows.Add(row0);

            List <Facility> facilities = FacilityController.GetInstance().ListFacility();


            foreach (Facility facility in facilities)
            {
                TableRow  row     = new TableRow();
                TableCell cell001 = new TableCell();
                cell001.Text = facility.Name;
                row.Cells.Add(cell001);

                foreach (string role in dataRoles)
                {
                    Access    access  = AccessController.GetInstance().RetrieveAccessCreateIfNotExists(facility.Id, role);
                    TableCell cell002 = new TableCell();
                    cell002.Text = role;
                    CheckBox cb = new CheckBox();
                    cb.ID              = access.Id.ToString();
                    cb.Checked         = access.granted;
                    cb.CheckedChanged += Checked_Changed;
                    cb.CssClass        = "w3-padding";

                    cell002.Controls.Add(cb);
                    row.Cells.Add(cell002);
                }


                FacilityTable.Rows.Add(row);
            }
        }
示例#27
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);
            }
        }
        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);
            }
        }
        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);
            }
        }