Ejemplo n.º 1
0
        public void TestCreate_ShouldSucceed()
        {
            //Set up dto
            ArtefactDto artefact = new ArtefactDto()
            {
                Name               = "Test",
                Description        = "Test",
                Measurement_Width  = 1,
                Measurement_Height = 2,
                Measurement_Length = 3,
                AcquisitionDate    = DateTime.Now,
                Image              = testImage
            };

            //Make test request
            ArtefactDto artefactResult = _controller.Create(artefact);

            //Assert Values
            Assert.IsNotNull(artefactResult);
            Assert.IsNotNull(artefactResult.Id);
            Assert.IsTrue(artefactResult.Id != 0);
            Assert.AreEqual(artefact.Name, artefactResult.Name);
            Assert.AreEqual(artefact.Description, artefactResult.Description);
            Assert.IsNotNull(artefactResult.CreatedDate);
            Assert.IsNotNull(artefactResult.ModifiedDate);
        }
        // GET: Artefacts/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            var request = new HTTPrequest();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ArtefactDto artefact = await request.Get <ArtefactDto>("api/artefact/" + id);

            if (artefact == null)
            {
                return(HttpNotFound());
            }
            // ARTEFACT CATEGORY DROPDOWN
            List <SelectListItem> categoryDropdown = new List <SelectListItem>();

            categoryDropdown = await PopulateCategoryDropdown();

            ViewBag.CategoryList = categoryDropdown;

            // ARTEFACT ZONE DROPDOWN
            List <SelectListItem> zoneDropdown = new List <SelectListItem>();

            zoneDropdown = await PopulateZoneDropdownList();

            ViewBag.ZoneList = zoneDropdown;


            return(View(artefact));
        }
        public async Task <ActionResult> Create(ArtefactDto artefact, HttpPostedFileBase imageFile)
        {
            // ARTEFACT CATEGORY DROPDOWN
            List <SelectListItem> categoryDropdown = new List <SelectListItem>();

            categoryDropdown = await PopulateCategoryDropdown();

            ViewBag.CategoryList = categoryDropdown;

            // ARTEFACT ZONE DROPDOWN
            List <SelectListItem> zoneDropdown = new List <SelectListItem>();

            zoneDropdown = await PopulateZoneDropdownList();

            ViewBag.ZoneList = zoneDropdown;

            // Checks Name is not Null or Empty
            if (string.IsNullOrEmpty(artefact.Name))
            {
                ViewBag.ValidationName = "Name field is required.";
                return(View(artefact));
            }

            ArtefactDto newArtefact = new ArtefactDto();

            newArtefact.Id                 = artefact.Id;
            newArtefact.Name               = artefact.Name;
            newArtefact.Description        = artefact.Description;
            newArtefact.ModifiedDate       = artefact.ModifiedDate;
            newArtefact.Measurement_Height = artefact.Measurement_Height;
            newArtefact.Measurement_Length = artefact.Measurement_Length;
            newArtefact.Measurement_Width  = artefact.Measurement_Width;
            newArtefact.ArtefactCategory   = artefact.ArtefactCategory;
            newArtefact.XBound             = artefact.XBound;
            newArtefact.YBound             = artefact.YBound;

            if (ModelState.IsValid)
            {
                var request = new HTTPrequest();
                HttpPostedFileBase imgFile = Request.Files["ImageFile"];
                if (imgFile != null)
                {
                    artefact.Image = new byte[imgFile.ContentLength];
                    imgFile.InputStream.Read(artefact.Image, 0, imgFile.ContentLength);
                    string fileExtension = Path.GetExtension(imgFile.FileName);
                    artefact.ImageFileType = fileExtension;
                }
                artefact = await request.Post <ArtefactDto>("api/artefact", artefact);

                return(RedirectToAction("Index", new { recentAction = "Created", recentName = artefact.Name, recentId = artefact.Id }));
            }
            else
            {
                return(View(artefact));
            }
        }
Ejemplo n.º 4
0
 public ArtefactDto Update([FromBody] ArtefactDto dto)
 {
     try
     {
         return(new ArtefactHandler(isTest).Update(dto));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 5
0
        public void TestUpdate_EmptyName()
        {
            //Get valid artefact
            ArtefactDto artefact = GetArtefact();

            artefact.Name        = string.Empty;
            artefact.Description = "Test Edit";
            artefact.Image       = testImage;

            _controller.Update(artefact);
        }
 public void SetupTest()
 {
     _controller         = new API.Controllers.TourArtefactController(true);
     _tourController     = new API.Controllers.TourController(true);
     _artefactController = new API.Controllers.ArtefactController(true);
     ArtefactDto       artefact       = CreateTestArtefact();
     ArtefactSimpleDto artefactSimple = new ArtefactSimpleDto()
     {
         Id = artefact.Id
     };
 }
Ejemplo n.º 7
0
        public ArtefactDto Update(ArtefactDto dto)
        {
            if (string.IsNullOrEmpty(dto.Name))
            {
                throw new ArgumentNullException("Name");
            }

            Artefact artefact = Db.Artefacts.FirstOrDefault(m => m.Id == dto.Id);

            if (artefact == null)
            {
                NotFoundException();
            }

            artefact.Name               = dto.Name;
            artefact.Description        = dto.Description;
            artefact.Image              = dto.Image;
            artefact.ImageFileType      = dto.ImageFileType;
            artefact.AdditionalComments = dto.AdditionalComments;
            artefact.AcquisitionDate    = dto.AcquisitionDate;
            artefact.Measurement_Height = dto.Measurement_Height;
            artefact.Measurement_Length = dto.Measurement_Length;
            artefact.Measurement_Width  = dto.Measurement_Width;
            artefact.ArtefactStatus     = (int)dto.ArtefactStatus;
            artefact.IsDeleted          = dto.IsDeleted;
            artefact.ModifiedDate       = DateTime.UtcNow;
            artefact.XBound             = dto.XBound;
            artefact.YBound             = dto.YBound;

            //Process zone
            if (dto.Zone != null && dto.Zone.Id > 0)
            {
                artefact.Zone = Db.Zones.Find(dto.Zone.Id);
            }
            else
            {
                artefact.Zone = null;
            }

            //Process Category
            if (dto.ArtefactCategory != null && dto.ArtefactCategory.Id > 0)
            {
                artefact.ArtefactCategory = Db.ArtefactCategories.Find(dto.ArtefactCategory.Id);
            }
            else
            {
                artefact.ArtefactCategory = null;
            }

            Db.SaveChanges();

            return(Mapper.Map <ArtefactDto>(artefact));
        }
Ejemplo n.º 8
0
        public void TestGetById_ValidId()
        {
            //Get a valid artefact
            ArtefactDto validArtefact = GetArtefact();

            //Try to get this artefact
            ArtefactDto artefactResult = _controller.GetById(validArtefact.Id);

            Assert.IsNotNull(artefactResult);
            Assert.IsNotNull(artefactResult.Id);
            Assert.AreEqual(validArtefact.Id, artefactResult.Id);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            try {
                var         request  = new HTTPrequest();
                ArtefactDto artefact = await request.Get <ArtefactDto>("api/artefact/" + id);

                await request.Delete("api/artefact/" + id);

                return(RedirectToAction("Index", new { recentAction = "Deleted", recentName = artefact.Name, recentId = artefact.Id }));
            }
            catch (Exception) {
                throw;
            }
        }
Ejemplo n.º 10
0
        public ArtefactDto Create(ArtefactDto dto)
        {
            if (string.IsNullOrEmpty(dto.Name))
            {
                throw new ArgumentNullException("Name");
            }

            Artefact artefact = new Artefact
            {
                Name               = dto.Name,
                Description        = dto.Description,
                Image              = dto.Image,
                ImageFileType      = dto.ImageFileType,
                AdditionalComments = dto.AdditionalComments,
                AcquisitionDate    = dto.AcquisitionDate,
                Radius_Of_Effect   = dto.Radius_Of_Effect,
                Coord_X            = dto.Coord_X,
                Coord_Y            = dto.Coord_Y,
                Activation         = dto.Activation,
                ArtefactStatus     = (int)dto.ArtefactStatus,
                CreatedDate        = DateTime.UtcNow,
                ModifiedDate       = DateTime.UtcNow,
                IsDeleted          = false
            };

            //Add Zone
            if (dto.Zone != null && dto.Zone.Id > 0)
            {
                artefact.Zone = Db.Zones.Find(dto.Zone.Id);
            }

            //Add category
            if (dto.ArtefactCategory != null && dto.ArtefactCategory.Id > 0)
            {
                artefact.ArtefactCategory = Db.ArtefactCategories.Find(dto.ArtefactCategory.Id);
            }

            //Add Beacon
            if (dto.Beacon != null && dto.Beacon.Id > 0)
            {
                artefact.Beacon = Db.Beacons.Find(dto.Beacon.Id);
            }

            Db.Artefacts.Add(artefact);

            Db.SaveChanges();

            return(Mapper.Map <ArtefactDto>(artefact));
        }
Ejemplo n.º 11
0
        public void TestGetFiltered_AllFilters()
        {
            //Create Artefact for getfiltered validation
            ArtefactDto validArtefact = CreateTestArtefact();

            var results = _controller.GetFiltered(new ArtefactFilter()
            {
                isDeleted = false, numPerPage = 100, pageNumber = 0
            });

            Assert.IsNotNull(results);
            Assert.IsTrue(!results.Any(m => m.IsDeleted));
            Assert.IsTrue(results.Count <= 100);
            Assert.IsTrue(results.Count == results.Distinct().Count());
        }
        // GET: Artefacts/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var         request  = new HTTPrequest();
            ArtefactDto artefact = await request.Get <ArtefactDto>("api/artefact/" + id);

            if (artefact == null)
            {
                return(HttpNotFound());
            }
            return(View(artefact));
        }
        public async Task <ActionResult> Edit(ArtefactDto artefact, HttpPostedFileBase imageFile)
        {
            // Checks Name is not Null or Empty
            if (string.IsNullOrEmpty(artefact.Name))
            {
                ViewBag.ValidationName = "Name field is required.";
                return(View(artefact));
            }

            var         request          = new HTTPrequest();
            ArtefactDto artefact_editted = await request.Get <ArtefactDto>("api/artefact/" + artefact.Id);

            if (ModelState.IsValid)
            {
                artefact_editted.Name               = artefact.Name;
                artefact_editted.Description        = artefact.Description;
                artefact_editted.Measurement_Length = artefact.Measurement_Length;
                artefact_editted.Measurement_Height = artefact.Measurement_Height;
                artefact_editted.Measurement_Width  = artefact.Measurement_Width;
                artefact_editted.AdditionalComments = artefact.AdditionalComments;
                artefact_editted.ArtefactCategory   = artefact.ArtefactCategory;
                artefact_editted.Zone               = artefact.Zone;
                artefact_editted.ModifiedDate       = DateTime.Now;
                artefact_editted.XBound             = artefact.XBound;
                artefact_editted.YBound             = artefact.YBound;

                //  HttpPostedFileBase imgFile = Request.Files["ImageFile"];
                if (imageFile != null)
                {
                    artefact_editted.Image = new byte[imageFile.ContentLength];
                    imageFile.InputStream.Read(artefact_editted.Image, 0, imageFile.ContentLength);
                    string fileExtension = Path.GetExtension(imageFile.FileName);
                    artefact_editted.ImageFileType = fileExtension;
                }
                else
                {
                    artefact_editted.Image         = artefact_editted.Image;
                    artefact_editted.ImageFileType = artefact_editted.ImageFileType;
                }

                //if (artefact.Image != null) { artefact_editted.Image = artefact.Image; }

                await request.Put <ArtefactDto>("api/artefact", artefact_editted);

                return(RedirectToAction("Index", new { recentAction = "Editted", recentName = artefact.Name, recentId = artefact.Id }));
            }
            return(View(artefact));
        }
Ejemplo n.º 14
0
        public void TestCreate_EmptyName()
        {
            //Set up dto
            ArtefactDto artefact = new ArtefactDto()
            {
                Name               = string.Empty,
                Description        = "Test",
                Measurement_Width  = 1,
                Measurement_Height = 2,
                Measurement_Length = 3,
                AcquisitionDate    = DateTime.Now,
                Image              = testImage
            };

            _controller.Create(artefact);
        }
Ejemplo n.º 15
0
        public void TestUpdate_NoDescription()
        {
            //Get valid artefact
            ArtefactDto artefact = GetArtefact();

            artefact.Name        = "Test Edit";
            artefact.Description = null;
            artefact.Image       = testImage;

            ArtefactDto updatedArtefact = _controller.Update(artefact);

            Assert.IsNotNull(updatedArtefact);
            Assert.IsNotNull(updatedArtefact.Id);
            Assert.AreEqual(artefact.Id, updatedArtefact.Id);
            Assert.AreEqual(artefact.Name, updatedArtefact.Name);
            Assert.AreEqual(artefact.Description, updatedArtefact.Description);
        }
        ArtefactDto CreateTestArtefact()
        {
            ArtefactDto artefact = new ArtefactDto()
            {
                Name               = "Test",
                Description        = "Test",
                Measurement_Height = 1,
                Measurement_Length = 2,
                Measurement_Width  = 3,
                AcquisitionDate    = DateTime.Now,
                Image              = testImage
            };

            artefact = _artefactController.Create(artefact);

            return(artefact);
        }
Ejemplo n.º 17
0
        public ArtefactDto Create(ArtefactDto dto)
        {
            if (string.IsNullOrEmpty(dto.Name))
            {
                throw new ArgumentNullException("Name");
            }

            Artefact artefact = new Artefact
            {
                Name               = dto.Name,
                Description        = dto.Description,
                Image              = dto.Image,
                ImageFileType      = dto.ImageFileType,
                AdditionalComments = dto.AdditionalComments,
                AcquisitionDate    = dto.AcquisitionDate,
                Measurement_Height = dto.Measurement_Height,
                Measurement_Length = dto.Measurement_Length,
                Measurement_Width  = dto.Measurement_Width,
                ArtefactStatus     = (int)dto.ArtefactStatus,
                CreatedDate        = DateTime.UtcNow,
                ModifiedDate       = DateTime.UtcNow,
                IsDeleted          = false,
                UniqueCode         = CalculateUniqueCode(),
                XBound             = dto.XBound,
                YBound             = dto.YBound
            };

            //Add Zone
            if (dto.Zone != null && dto.Zone.Id > 0)
            {
                artefact.Zone = Db.Zones.Find(dto.Zone.Id);
            }

            //Add category
            if (dto.ArtefactCategory != null && dto.ArtefactCategory.Id > 0)
            {
                artefact.ArtefactCategory = Db.ArtefactCategories.Find(dto.ArtefactCategory.Id);
            }

            Db.Artefacts.Add(artefact);

            Db.SaveChanges();

            return(Mapper.Map <ArtefactDto>(artefact));
        }
Ejemplo n.º 18
0
        public void TestGetFiltered_IsDeleted()
        {
            //Create a artefact to test on
            ArtefactDto validArtefact = CreateTestArtefact();

            //delete for test
            _controller.Delete(validArtefact.Id);

            var results = _controller.GetFiltered(new ArtefactFilter()
            {
                isDeleted = true, numPerPage = 100, pageNumber = 0
            });

            Assert.IsNotNull(results);
            Assert.IsTrue(!results.Any(m => !m.IsDeleted));
            Assert.IsTrue(results.Count <= 100);
            Assert.IsTrue(results.Count == results.Distinct().Count());
        }
Ejemplo n.º 19
0
        public void TestDelete_ValidId()
        {
            //Get valid artefact
            ArtefactDto validArtefact = GetArtefact();

            //Delete artefact
            bool result = _controller.Delete(validArtefact.Id);

            Assert.IsTrue(result);

            //Get artefact for comparison
            ArtefactDto artefactResult = _controller.GetById(validArtefact.Id);

            Assert.IsNotNull(artefactResult);
            Assert.IsNotNull(artefactResult.Id);
            Assert.AreEqual(validArtefact.Id, artefactResult.Id);
            Assert.IsTrue(artefactResult.IsDeleted);
        }
Ejemplo n.º 20
0
        public void TestUpdate_InvalidId()
        {
            //Get valid artefact
            ArtefactDto artefact = GetArtefact();

            ArtefactDto updatedArtefact = new ArtefactDto()
            {
                Id                 = 0,
                Name               = artefact.Name,
                Description        = artefact.Description,
                Measurement_Height = artefact.Measurement_Height,
                Measurement_Length = artefact.Measurement_Length,
                Measurement_Width  = artefact.Measurement_Width,
                AcquisitionDate    = artefact.AcquisitionDate,
                Image              = artefact.Image
            };

            _controller.Update(updatedArtefact);
        }
Ejemplo n.º 21
0
        public void TestUpdate_NoImage()
        {
            //Get valid artefact
            ArtefactDto artefact = GetArtefact();

            artefact.Name               = "Test Edit";
            artefact.Description        = "Test Edit";
            artefact.Image              = null;
            artefact.Measurement_Width  = 1;
            artefact.Measurement_Height = 2;
            artefact.Measurement_Length = 3;
            artefact.AcquisitionDate    = DateTime.Now;

            ArtefactDto updatedArtefact = _controller.Update(artefact);

            Assert.IsNotNull(updatedArtefact);
            Assert.IsNotNull(updatedArtefact.Id);
            Assert.AreEqual(artefact.Id, updatedArtefact.Id);
            Assert.AreEqual(artefact.Name, updatedArtefact.Name);
            Assert.AreEqual(artefact.Description, updatedArtefact.Description);
        }
Ejemplo n.º 22
0
        public void TestCreate_NoImage()
        {
            //Set up dto
            ArtefactDto artefact = new ArtefactDto()
            {
                Name               = "Test",
                Description        = "Test",
                Measurement_Width  = 1,
                Measurement_Height = 2,
                Measurement_Length = 3,
                AcquisitionDate    = DateTime.Now,
                Image              = null
            };

            //Make test request
            ArtefactDto artefactResult = _controller.Create(artefact);

            //Assert Values
            Assert.IsNotNull(artefactResult);
            Assert.IsNotNull(artefactResult.Id);
            Assert.IsTrue(artefactResult.Id != 0);
        }
Ejemplo n.º 23
0
        public async Task <ActionResult> PostApiExample(string name, string description)
        {
            try
            {
                var request = new HTTPrequest();

                ArtefactDto dto = new ArtefactDto()
                {
                    Name        = name,
                    Description = description,
                    //More properties here .....
                };

                dto = await request.Post <ArtefactDto>("api/artefact", dto);

                return(View(dto));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 24
0
        public async Task <ActionResult> Index()
        {
            var requestArtefacts = new HTTPrequest();

            //Get list of Artefacts and pass Count of Artefact Entires
            List <ArtefactDto> artefactsMasterList = await GetArtefacts();

            int artefactsCount = artefactsMasterList.Count;

            ViewBag.TotalArtefacts = artefactsCount;


            //Get the most recently modified Artefact and pass NAME, ID, MODIFIED DATE via ViewBag
            List <ArtefactDto> orderedArtefactMasterList = artefactsMasterList.OrderByDescending(m => m.ModifiedDate).ToList();

            if (orderedArtefactMasterList.Count <= 0)
            {
            }
            else
            {
                ArtefactDto mostRecentArtefact = orderedArtefactMasterList.ElementAt(0);
                ViewBag.mostRecentArtefactName    = mostRecentArtefact.Name;
                ViewBag.mostRecentArtefactId      = mostRecentArtefact.Id;
                ViewBag.mostRecentArtefactModDate = mostRecentArtefact.ModifiedDate;
            }


            //Get list of Artefacts and pass Count of Artefact Entires
            List <ArtefactInfoDto> artefactInfoMasterList = await GetArtefactInfo();

            int artefactInfoCount = artefactInfoMasterList.Count;

            ViewBag.TotalArtefactContentEntries = artefactInfoCount;

            //Get list of Exibitions and pass Count of Artefact Entires
            List <ExhibitionDto> exhibitionsMasterList = await GetExhibitions();

            List <ExhibitionDto> futureExhibitions = exhibitionsMasterList.Where(e => e.StartDate >= DateTime.Today).ToList().OrderBy(e => e.StartDate).ToList();
            int           exhibitionCountFuture    = futureExhibitions.Count();
            ExhibitionDto nextExhibition;

            if (exhibitionCountFuture > 0)
            {
                nextExhibition = futureExhibitions.ElementAt(0);
                ViewBag.FutureExhibitionCount = exhibitionCountFuture;
                ViewBag.NextExhibitionId      = nextExhibition.Id;
                ViewBag.NextExhibitionName    = nextExhibition.Name;
                ViewBag.NextExhibitionStart   = nextExhibition.StartDate.ToShortDateString();
            }
            else
            {
                nextExhibition = null;
                ViewBag.FutureExhibitionCount = 0;
            }

            //Get list of Store Items and pass Count of Artefact Entires
            List <StoreItemDto> storeItemsMasterList = await GetStoreItems();

            int    storeItemCount = storeItemsMasterList.Count;
            double costOfAllItems = 0;

            foreach (var item in storeItemsMasterList)
            {
                costOfAllItems = costOfAllItems + item.Cost;
            }
            double storeItemAvgCost = costOfAllItems / storeItemCount;

            ViewBag.TotalStoreItems = storeItemCount;
            ViewBag.AverageItemCost = storeItemAvgCost;



            return(View());
        }
Ejemplo n.º 25
0
        public ArtefactDto Update(ArtefactDto dto)
        {
            if (string.IsNullOrEmpty(dto.Name))
            {
                throw new ArgumentNullException("Name");
            }

            Artefact artefact = Db.Artefacts.FirstOrDefault(m => m.Id == dto.Id);

            if (artefact == null)
            {
                NotFoundException();
            }

            artefact.Name               = dto.Name;
            artefact.Description        = dto.Description;
            artefact.Image              = dto.Image;
            artefact.ImageFileType      = dto.ImageFileType;
            artefact.AdditionalComments = dto.AdditionalComments;
            artefact.AcquisitionDate    = dto.AcquisitionDate;
            artefact.Radius_Of_Effect   = dto.Radius_Of_Effect;
            artefact.Coord_X            = dto.Coord_X;
            artefact.Coord_Y            = dto.Coord_Y;
            artefact.Activation         = dto.Activation;
            artefact.ArtefactStatus     = (int)dto.ArtefactStatus;
            artefact.IsDeleted          = dto.IsDeleted;
            artefact.ModifiedDate       = DateTime.UtcNow;

            // Process Beacon
            if (dto.Beacon.Id > 0)
            {
                artefact.Beacon = Db.Beacons.Find(dto.Beacon.Id);
            }
            else
            {
                _ = artefact.Beacon;
                artefact.Beacon = null;
            }

            // Process Category
            if (dto.ArtefactCategory.Id > 0)
            {
                artefact.ArtefactCategory = Db.ArtefactCategories.Find(dto.ArtefactCategory.Id);
            }
            else
            {
                _ = artefact.ArtefactCategory;
                artefact.ArtefactCategory = null;
            }

            // Process zone
            if (dto.Zone.Id > 0)
            {
                artefact.Zone = Db.Zones.Find(dto.Zone.Id);
            }
            else
            {
                _             = artefact.Zone;
                artefact.Zone = null;
            }

            Db.SaveChanges();

            return(Mapper.Map <ArtefactDto>(artefact));
        }
        // GET: ArtefactInfo
        public async Task <ActionResult> Index(int?artefactId, string sortOrder, string currentFilter, string searchString, int?page)
        {
            var requestArtefact          = new HTTPrequest();
            var requestArtefactsInfoList = new HTTPrequest();

            ViewBag.CurrentSort         = sortOrder;
            ViewBag.IdSortParm          = String.IsNullOrEmpty(sortOrder) ? "id_desc" : "";
            ViewBag.NameSortParm        = sortOrder == "Name" ? "name_desc" : "Name";
            ViewBag.DescriptionSortParm = sortOrder == "Description" ? "description_desc" : "Description";
            ViewBag.TypeSortParm        = sortOrder == "Type" ? "type_desc" : "Type";

            ViewBag.ArtefactID = artefactId;
            // Retrives a list of All Artefacts if user has not navaigated through a particular Artefact Id
            List <ArtefactInfoDto> artefactContentMasterList = new List <ArtefactInfoDto>();

            if (artefactId == null)
            {
                artefactContentMasterList = await requestArtefactsInfoList.Get <List <ArtefactInfoDto> >("api/artefactInfo?pageNumber=0&numPerPage=500&isDeleted=false");
            }
            else
            {
                artefactContentMasterList = await requestArtefactsInfoList.Get <List <ArtefactInfoDto> >("api/artefactInfo?artefactId=" + artefactId + "&pageNumber=0&numPerPage=500&isDeleted=false");

                ArtefactDto artefact = await requestArtefact.Get <ArtefactDto>("api/artefact/" + artefactId);

                ViewBag.ArtefactName = artefact.Name;
            }
            IEnumerable <ArtefactInfoDto> artefactContentFiltered = artefactContentMasterList.ToList();

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            ViewBag.CurrentFilter = searchString;


            if (!String.IsNullOrEmpty(searchString))
            {
                artefactContentFiltered = artefactContentFiltered.Where(a => a.Description.Contains(searchString));
            }

            var artefactsContent = artefactContentFiltered;

            switch (sortOrder)
            {
            case "id_desc":
                artefactsContent = artefactsContent.OrderByDescending(a => a.Id);
                break;

            case "Description":
                artefactsContent = artefactsContent.OrderBy(a => a.Description);
                break;

            case "description_desc":
                artefactsContent = artefactsContent.OrderByDescending(a => a.Description);
                break;

            case "Name":
                artefactsContent = artefactsContent.OrderBy(a => a.Artefact.Name);
                break;

            case "name_desc":
                artefactsContent = artefactsContent.OrderByDescending(a => a.Artefact.Name);
                break;

            case "Type":
                artefactsContent = artefactsContent.OrderBy(a => a.ArtefactInfoType);
                break;

            case "type_desc":
                artefactsContent = artefactsContent.OrderByDescending(a => a.ArtefactInfoType);
                break;

            default:
                artefactsContent = artefactsContent.OrderBy(a => a.Id);
                break;
            }

            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            return(View(artefactsContent.ToPagedList(pageNumber, pageSize)));
        }