Exemple #1
0
        public async Task <List <SelectListItem> > PopulateZoneDropdownList()
        {
            var request = new HTTPrequest();
            List <ZoneSimpleDto> museumZones = await request.Get <List <ZoneSimpleDto> >("api/zone?pageNumber=0&numPerPage=5-0&isDeleted=false");

            List <SelectListItem> zoneDropdown = new List <SelectListItem>();

            zoneDropdown.Add(new SelectListItem()
            {
                Text  = "Select Zone",
                Value = "0"
            });
            if (museumZones != null && museumZones.Any())
            {
                foreach (var zone in museumZones)
                {
                    zoneDropdown.Add(new SelectListItem()
                    {
                        Text  = zone.Id + ": " + zone.Name,
                        Value = zone.Id.ToString()
                    });
                }
            }
            return(zoneDropdown);
        }
Exemple #2
0
        public async Task <List <SelectListItem> > PopulateCategoryDropdown()
        {
            var request = new HTTPrequest();
            List <ArtefactCategorySimpleDto> artefactCateories = await request.Get <List <ArtefactCategorySimpleDto> >("api/artefactCatergory?pageNumber=0&numPerPage=5-0&isDeleted=false");

            List <SelectListItem> categoryDropdown = new List <SelectListItem>();

            categoryDropdown.Add(new SelectListItem()
            {
                Text  = "Select Category",
                Value = "0"
            });
            if (artefactCateories != null && artefactCateories.Any())
            {
                foreach (var category in artefactCateories)
                {
                    categoryDropdown.Add(new SelectListItem()
                    {
                        Text  = category.Id + ": " + category.Name,
                        Value = category.Id.ToString()
                    });
                }
            }
            return(categoryDropdown);
        }
Exemple #3
0
        // GET: Artefacts/Create
        public async Task <ActionResult> Create()
        {
            var request = new HTTPrequest();

            // 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;

            //ARTEFACT BEACON DROPDOWN
            List <SelectListItem> beaconDropdown = new List <SelectListItem>();

            beaconDropdown = await PopulateBeaconDropdownList();

            ViewBag.BeaconList = beaconDropdown;

            return(View());
        }
Exemple #4
0
        // GET: ArtefactCategoryDtoes
        public async Task <ActionResult> Index(string sortOrder, string currentFilter, string searchString, int?page, string recentAction, string recentName, string recentId)
        {
            var request = new HTTPrequest();

            //Pass through most recent action details if redirected from an action
            if (recentAction != null && recentAction.Count() > 0)
            {
                ViewBag.Action     = recentAction;
                ViewBag.RecentName = recentName;
                ViewBag.RecentId   = recentId;
            }
            ViewBag.CurrentSort  = sortOrder;
            ViewBag.IdSortParm   = String.IsNullOrEmpty(sortOrder) ? "id_desc" : "";
            ViewBag.NameSortParm = sortOrder == "Name" ? "name_desc" : "Name";
            List <ArtefactCategoryDto> categoryMasterList = await request.Get <List <ArtefactCategoryDto> >("api/artefactCatergory?pageNumber=0&numPerPage=500&isDeleted=false");

            IEnumerable <ArtefactCategoryDto> categoriesFiltered = categoryMasterList.ToList();

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


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

            var categories = categoriesFiltered;

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

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

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

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

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

            return(View(categories.ToPagedList(pageNumber, pageSize)));
        }
Exemple #5
0
        public async Task <ActionResult> Edit(ArtefactCategoryDto category, HttpPostedFileBase imageFile)
        {
            var request = new HTTPrequest();
            ArtefactCategoryDto category_editted = await request.Get <ArtefactCategoryDto>("api/artefactCatergory/" + category.Id);

            if (ModelState.IsValid)
            {
                category_editted.Name         = category.Name;
                category_editted.Description  = category.Description;
                category_editted.ModifiedDate = DateTime.Now;
                HttpPostedFileBase imgFile = Request.Files["ImageFile"];

                if (imageFile != null)
                {
                    category_editted.Image = new byte[imageFile.ContentLength];
                    imageFile.InputStream.Read(category_editted.Image, 0, imageFile.ContentLength);
                }
                else
                {
                    category_editted.Image = category_editted.Image;
                }

                await request.Put <ArtefactCategoryDto>("api/artefactCatergory", category_editted);

                return(RedirectToAction("Index", new { recentAction = "Editted", recentName = category.Name, recentId = category.Id }));
            }
            return(View(category));
        }
Exemple #6
0
        public async Task <List <SelectListItem> > PopulateBeaconDropdownList()
        {
            var request = new HTTPrequest();
            List <BeaconSimpleDto> museumBeacons = await request.Get <List <BeaconSimpleDto> >("api/beacon?pageNumber=0&numPerPage=5-0&isDeleted=false");

            List <SelectListItem> beaconDropdown = new List <SelectListItem>();

            beaconDropdown.Add(new SelectListItem()
            {
                Text  = "Select Beacon",
                Value = "0"
            });
            if (museumBeacons != null && museumBeacons.Any())
            {
                foreach (var beacon in museumBeacons)
                {
                    beaconDropdown.Add(new SelectListItem()
                    {
                        Text  = beacon.Id + ": " + beacon.Name,
                        Value = beacon.Id.ToString()
                    });
                }
            }
            return(beaconDropdown);
        }
Exemple #7
0
        public async Task <ActionResult> Create(StoreItemDto storeItem, HttpPostedFileBase imageFile)
        {
            // Checks Name is not Null or Empty
            if (string.IsNullOrEmpty(storeItem.Name))
            {
                ViewBag.ValidationName = "Name field is required.";
                return(View(storeItem));
            }
            StoreItemDto newStoreItem = new StoreItemDto();

            newStoreItem.Id           = storeItem.Id;
            newStoreItem.Name         = storeItem.Name;
            newStoreItem.Description  = storeItem.Description;
            newStoreItem.ModifiedDate = storeItem.ModifiedDate;
            newStoreItem.InStock      = storeItem.InStock;
            newStoreItem.Cost         = storeItem.Cost;

            if (ModelState.IsValid)
            {
                var request = new HTTPrequest();
                storeItem = await request.Post <StoreItemDto>("api/storeItem", storeItem);

                return(RedirectToAction("Index", new { recentAction = "Created", recentName = storeItem.Name, recentId = storeItem.Id }));
            }
            else
            {
                var request = new HTTPrequest();
                return(View());
            }
        }
        public async Task <ActionResult> Create(StoreItemImageDto storeItemImage, HttpPostedFileBase storeItemImageFile)
        {
            StoreItemImageDto newstoreItemImage = new StoreItemImageDto();

            newstoreItemImage.Id           = storeItemImage.Id;
            newstoreItemImage.StoreItem    = storeItemImage.StoreItem;
            newstoreItemImage.CreatedDate  = DateTime.Now;
            newstoreItemImage.ModifiedDate = DateTime.Now;

            if (ModelState.IsValid)
            {
                var request = new HTTPrequest();
                //HttpPostedFileBase newFile = Request.Files["storeItemImageFile"];
                //HttpPostedFileBase newFile = storeItemImageFile;
                if (storeItemImageFile != null && storeItemImageFile.ContentLength > 0)
                {
                    storeItemImage.Image = new byte[storeItemImageFile.ContentLength];
                    storeItemImageFile.InputStream.Read(storeItemImage.Image, 0, storeItemImageFile.ContentLength);
                    string fileExtension = Path.GetExtension(storeItemImageFile.FileName);
                    storeItemImage.FileType = fileExtension;
                    if (storeItemImageFile == null)
                    {
                        throw new ArgumentException("file");
                    }
                }

                await request.Post <StoreItemImageDto>("api/storeItemImage", storeItemImage);

                return(RedirectToAction("Index"));
            }
            return(View(storeItemImage));
        }
        // GET: TourDtoes
        public async Task <ActionResult> Index(int?tId, string recentAction, string recentNameT, string recentIdT, string recentNameA, string recentIdA)
        {
            if (tId.HasValue == false)
            {
                return(RedirectToAction("Index", "Tours"));
            }
            //Pass through most recent action details if redirected from an action
            if (recentAction != null && recentAction.Count() > 0)
            {
                ViewBag.Action      = recentAction;
                ViewBag.RecentNameT = recentNameT;
                ViewBag.RecentIdT   = recentIdT;
                ViewBag.RecentNameA = recentNameA;
                ViewBag.RecentIdA   = recentIdA;
            }
            var request = new HTTPrequest();

            ViewBag.tourId = tId;
            TourDto tour = await request.Get <TourDto>("api/tour/" + tId);

            ViewBag.tourName = tour.Name;
            List <TourArtefactDto> toursArtefactsMasterlist = await request.Get <List <TourArtefactDto> >("api/tourArtefact?pageNumber=0&numPerPage=999999&isDeleted=false");

            List <TourArtefactDto> tourArtefactsFiltered = toursArtefactsMasterlist.Where(m => m.Tour.Id.ToString() == tour.Id.ToString()).ToList();

            //viewModel = await request.Get<List<TourDto>>("api/tour?tourId=" + tourId + "&pageNumber=0&numPerPage=500&isDeleted=false");
            List <TourArtefactDto> tourArtefactList = tourArtefactsFiltered.OrderBy(m => m.Order).ToList();

            ViewBag.tourArtefactList = tourArtefactList;

            List <TourArtefactDto> viewModel = tourArtefactList;

            return(View(viewModel));
        }
        public async Task <List <StoreItemDto> > GetStoreItems()
        {
            var request = new HTTPrequest();
            List <StoreItemDto> storeItemsMasterList = await request.Get <List <StoreItemDto> >("api/storeItem?pageNumber=0&numPerPage=99999&isDeleted=false");

            return(storeItemsMasterList);
        }
        public async Task <ActionResult> Edit(ArtefactInfoDto artefactInfo, HttpPostedFileBase ArtefactInfoFile)
        {
            var             request = new HTTPrequest();
            ArtefactInfoDto artefactInfo_editted = await request.Get <ArtefactInfoDto>("api/artefactInfo/" + artefactInfo.Id.ToString());

            // Checks Name is not Null or Empty
            if (artefactInfo.Artefact.Id.ToString() == null || string.IsNullOrEmpty(artefactInfo.Artefact.Id.ToString()))
            {
                ViewBag.ValidationName = "Artefact is required.";
                return(View(artefactInfo));
            }

            if (ModelState.IsValid)
            {
                artefactInfo_editted.Artefact         = artefactInfo.Artefact;
                artefactInfo_editted.Content          = artefactInfo.Content;
                artefactInfo_editted.Description      = artefactInfo.Description;
                artefactInfo_editted.ArtefactInfoType = artefactInfo.ArtefactInfoType;
                if (ArtefactInfoFile != null)
                {
                    HttpPostedFileBase mediaFile = Request.Files["ArtefactInfoFile"];

                    artefactInfo_editted.File = new byte[mediaFile.ContentLength];
                    mediaFile.InputStream.Read(artefactInfo_editted.File, 0, mediaFile.ContentLength);
                    string fileExtension = Path.GetExtension(mediaFile.FileName);
                    artefactInfo_editted.FileExtension = fileExtension;
                }


                artefactInfo = await request.Put <ArtefactInfoDto>("api/artefactInfo", artefactInfo_editted);

                return(RedirectToAction("Index"));
            }
            return(View(artefactInfo));
        }
        // GET: ArtefactInfo/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var request = new HTTPrequest();

            ArtefactInfoDto artefactInfo = await request.Get <ArtefactInfoDto>("api/artefactInfo/" + id);

            if (artefactInfo == null)
            {
                return(HttpNotFound());
            }

            //TODO review this works
            HttpResponseMessage bytesResponse = await request.GetResponseMessage("api/artefactInfo/" + id + "/bytes");

            byte[] response = await bytesResponse.Content.ReadAsByteArrayAsync();

            //sets bytes to actual byte response
            artefactInfo.File = response;

            return(View(artefactInfo));
        }
Exemple #13
0
        public async Task <ActionResult> Create(ArtefactCategoryDto category, HttpPostedFileBase imageFile)
        {
            if (string.IsNullOrEmpty(category.Name))
            {
                ViewBag.ValidationName = "Name field is required.";
                return(View(category));
            }

            if (ModelState.IsValid)
            {
                var request = new HTTPrequest();

                HttpPostedFileBase imgFile = Request.Files["ImageFile"];
                if (imgFile != null)
                {
                    category.Image = new byte[imgFile.ContentLength];
                    imgFile.InputStream.Read(category.Image, 0, imgFile.ContentLength);
                }

                category = await request.Post <ArtefactCategoryDto>("api/artefactCatergory", category);

                return(RedirectToAction("Index", new { recentAction = "Created", recentName = category.Name, recentId = category.Id }));
            }

            return(View(category));
        }
Exemple #14
0
        public async Task <ActionResult> Edit(StoreItemDto storeItem, HttpPostedFileBase imageFile)
        {
            // Checks Name is not Null or Empty
            if (string.IsNullOrEmpty(storeItem.Name))
            {
                ViewBag.ValidationName = "Name field is required.";
                return(View(storeItem));
            }
            var          request           = new HTTPrequest();
            StoreItemDto storeItem_editted = await request.Get <StoreItemDto>("api/storeItem/" + storeItem.Id);

            if (ModelState.IsValid)
            {
                storeItem_editted.Name         = storeItem.Name;
                storeItem_editted.Description  = storeItem.Description;
                storeItem_editted.ModifiedDate = storeItem.ModifiedDate;
                storeItem_editted.InStock      = storeItem.InStock;
                storeItem_editted.Cost         = storeItem.Cost;
                storeItem_editted.ModifiedDate = DateTime.Now;

                await request.Put <StoreItemDto>("api/storeItem", storeItem_editted);

                return(RedirectToAction("Index", new { recentAction = "Editted", recentName = storeItem.Name, recentId = storeItem.Id }));
            }
            return(View(storeItem));
        }
        // 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 <List <ArtefactDto> > GetArtefacts()
        {
            var request = new HTTPrequest();
            List <ArtefactDto> artefactMasterList = await request.Get <List <ArtefactDto> >("api/artefact?pageNumber=0&numPerPage=99999&isDeleted=false");

            return(artefactMasterList);
        }
        public async Task <List <ExhibitionDto> > GetExhibitions()
        {
            var request = new HTTPrequest();
            List <ExhibitionDto> exhibitionsMasterList = await request.Get <List <ExhibitionDto> >("api/exhibition?pageNumber=0&numPerPage=99999&isDeleted=false");

            return(exhibitionsMasterList);
        }
        // GET: TourDtoes/Create
        public async Task <ActionResult> Create(int?tourId)
        {
            bool tour_Selected = tourId.HasValue;

            ViewBag.TourSelected = tour_Selected;
            var request = new HTTPrequest();


            List <TourSimpleDto>  toursList    = new List <TourSimpleDto>();
            TourSimpleDto         tour         = new TourSimpleDto();
            List <SelectListItem> tourDropdown = new List <SelectListItem>();

            // Checks if page was access from Index of all MediaFiles, or Direct from a particular artefact
            if (tour_Selected == true)
            {
                tour = await request.Get <TourSimpleDto>("api/tour/" + tourId);

                if (tour == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    tourDropdown.Add(new SelectListItem()
                    {
                        Text  = tour.Id + ": " + tour.Name,
                        Value = tour.Id.ToString()
                    });
                    ViewBag.TourName = tour.Name;
                    ViewBag.TourID   = tour.Id.ToString();
                }
            }
            else
            {
                toursList = await request.Get <List <TourSimpleDto> >("api/tour?pageNumber=0&numPerPage=5-0&isDeleted=false");

                if (toursList != null && toursList.Any())
                {
                    foreach (var tours in toursList)
                    {
                        tourDropdown.Add(new SelectListItem()
                        {
                            Text  = tours.Id + ": " + tours.Name,
                            Value = tours.Id.ToString()
                        });
                    }
                }
            }

            ViewBag.TourList = tourDropdown;
            //ARTEFACT DROPDOWN
            List <SelectListItem> artefactDropdown = new List <SelectListItem>();

            artefactDropdown = await PopulateArtefactDropdown();

            ViewBag.ArtefactList = artefactDropdown;
            return(View());
        }
        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));
            }
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            var     request = new HTTPrequest();
            TourDto tour    = await request.Get <TourDto>("api/tour/" + id);

            tour.IsDeleted = true;
            await request.Delete("api/tour/" + id.ToString());

            return(RedirectToAction("Index", new { recentAction = "Deleted", recentName = tour.Name, recentId = tour.Id }));
        }
        public async Task <ActionResult> Create(TourArtefactDto tourArtefact, int?tourId)
        {
            // Checks Order is not Negative or Empty
            if (tourArtefact.Order < 0 || tourArtefact.Order == null)
            {
                ViewBag.OrderValidation = "Order must be a positive integer.";
                return(View(tourArtefact));
            }
            bool tour_Selected = tourId.HasValue;
            //TOUR CATEGORY
            List <SelectListItem> tourDropdown = new List <SelectListItem>();

            if (tour_Selected)
            {
                tourDropdown = await PopulateTourDropdown(tour_Selected, tourId);
            }
            else
            {
                tourDropdown = await PopulateTourDropdown(tour_Selected, null);
            }
            ViewBag.TourList = tourDropdown;
            //ARTEFACT DROPDOWN
            List <SelectListItem> artefactDropdown = new List <SelectListItem>();

            artefactDropdown = await PopulateArtefactDropdown();

            ViewBag.ArtefactList = artefactDropdown;

            ViewBag.TourID = tourId.ToString();

            var     tourRequest = new HTTPrequest();
            TourDto tourCheck   = await tourRequest.Get <TourDto>("api/tour/" + tourArtefact.Tour.Id);

            TourArtefactDto newTourArtefact = new TourArtefactDto();

            if (tourCheck.Artefacts.Any(m => m.Order == tourArtefact.Order) && tourCheck.Artefacts.Any(m => m.Id == tourArtefact.Artefact.Id))
            {
                ViewBag.IndexAvail = false;
                return(View(newTourArtefact));
            }

            newTourArtefact.Artefact = await tourRequest.Get <ArtefactSimpleDto>("api/artefact/" + tourArtefact.Artefact.Id);

            TourSimpleDto tour = await tourRequest.Get <TourSimpleDto>("api/tour/" + tourArtefact.Tour.Id);

            newTourArtefact.Tour         = tour;
            newTourArtefact.Order        = tourArtefact.Order;
            newTourArtefact.CreatedDate  = DateTime.Now;
            newTourArtefact.ModifiedDate = DateTime.Now;
            var request = new HTTPrequest();
            await request.Post <TourArtefactDto>("api/tourArtefact", newTourArtefact);

            return(RedirectToAction("Index", "ToursArtefacts", new { tId = newTourArtefact.Tour.Id, recentAction = "Created", recentNameT = newTourArtefact.Tour.Name, recentIdT = newTourArtefact.Tour.Id, recentNameA = newTourArtefact.Artefact.Name, recentIdA = newTourArtefact.Artefact.Id }));
        }
Exemple #22
0
 public async Task Pickle(IGuildUser user)
 {
     try
     {
         System.Drawing.Image img = HTTPrequest.RequestImage(user.GetAvatarUrl());
         PhotoCommands.Picture("pickle", img, new Size(250, 250), new Point(404, 142));
         await Context.Channel.SendFileAsync("./Images/final.png");
     }
     catch (Exception)
     {
         await Context.Channel.SendMessageAsync("Avatar not found.");
     }
 }
Exemple #23
0
 public async Task Tobecontinued(IGuildUser user)
 {
     try
     {
         System.Drawing.Image img = HTTPrequest.RequestImage(user.GetAvatarUrl());
         PhotoCommands.Tobecontinued(img);
         await Context.Channel.SendFileAsync("./Images/final.png");
     }
     catch (Exception)
     {
         await Context.Channel.SendMessageAsync("Avatar not found.");
     }
 }
Exemple #24
0
 public async Task Computer(IGuildUser user)
 {
     try
     {
         System.Drawing.Image img = HTTPrequest.RequestImage(user.GetAvatarUrl());
         PhotoCommands.Picture("computer", img, new Size(235, 235), new Point(325, 20));
         await Context.Channel.SendFileAsync("./Images/final.png");
     }
     catch (Exception)
     {
         await Context.Channel.SendMessageAsync("Avatar not found");
     }
 }
Exemple #25
0
 public async Task Toilet(IGuildUser user)
 {
     try
     {
         System.Drawing.Image img = HTTPrequest.RequestImage(user.GetAvatarUrl());
         PhotoCommands.Picture("toilet", img, new Size(50, 50), new Point(120, 65));
         await Context.Channel.SendFileAsync("./Images/final.png");
     }
     catch (Exception ex)
     {
         await Context.Channel.SendMessageAsync("Avatar not found." + ex.Message);
     }
 }
        // GET: ArtefactInfo/Create
        public async Task <ActionResult> Create(int?artefactId)
        {
            bool artefact_Selected = artefactId.HasValue;

            ViewBag.ArteFactSelected = artefact_Selected;
            var request = new HTTPrequest();
            List <ArtefactSimpleDto> artefactsList    = new List <ArtefactSimpleDto>();
            ArtefactSimpleDto        artefact         = new ArtefactSimpleDto();
            List <SelectListItem>    artefactDropdown = new List <SelectListItem>();

            // Checks if page was access from Index of all MediaFiles, or Direct from a particular artefact
            if (artefact_Selected == true)
            {
                artefact = await request.Get <ArtefactSimpleDto>("api/artefact/" + artefactId);

                if (artefact == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    artefactDropdown.Add(new SelectListItem()
                    {
                        Text  = artefact.Id + ": " + artefact.Name,
                        Value = artefact.Id.ToString()
                    });
                    ViewBag.ArtefactName = artefact.Name;
                    ViewBag.ArtefactID   = artefact.Id.ToString();
                }
            }
            else
            {
                artefactsList = await request.Get <List <ArtefactSimpleDto> >("api/artefact?pageNumber=0&numPerPage=5-0&isDeleted=false");

                if (artefactsList != null && artefactsList.Any())
                {
                    foreach (var artefacts in artefactsList)
                    {
                        artefactDropdown.Add(new SelectListItem()
                        {
                            Text  = artefacts.Id + ": " + artefacts.Name,
                            Value = artefacts.Id.ToString()
                        });
                    }
                }
            }

            ViewBag.ArtefactList = artefactDropdown;
            return(View());
        }
        // GET: storeItemImage/Create
        public async Task <ActionResult> Create(int?storeItemId)
        {
            bool storeItem_Selected = storeItemId.HasValue;

            ViewBag.StoreItemSelected = storeItem_Selected;
            var request = new HTTPrequest();
            List <StoreItemSimpleDto> storeItemsList    = new List <StoreItemSimpleDto>();
            StoreItemSimpleDto        storeItem         = new StoreItemSimpleDto();
            List <SelectListItem>     storeItemDropdown = new List <SelectListItem>();

            // Checks if page was access from Index of all MediaFiles, or Direct from a particular storeItem
            if (storeItem_Selected == true)
            {
                storeItem = await request.Get <StoreItemSimpleDto>("api/storeItem/" + storeItemId);

                if (storeItem == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    storeItemDropdown.Add(new SelectListItem()
                    {
                        Text  = storeItem.Name,
                        Value = storeItem.Id.ToString()
                    });
                    ViewBag.StoreItemName = storeItem.Name;
                    ViewBag.StoreItemID   = storeItem.Id.ToString();
                }
            }
            else
            {
                storeItemsList = await request.Get <List <StoreItemSimpleDto> >("api/storeItem?pageNumber=0&numPerPage=5-0&isDeleted=false");

                if (storeItemsList != null && storeItemsList.Any())
                {
                    foreach (var storeItems in storeItemsList)
                    {
                        storeItemDropdown.Add(new SelectListItem()
                        {
                            Text  = storeItems.Id + ":" + storeItems.Name,
                            Value = storeItems.Id.ToString()
                        });
                    }
                }
            }

            ViewBag.StoreItemList = storeItemDropdown;
            return(View());
        }
        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;
            }
        }
Exemple #29
0
        public async Task <ActionResult> GetApiExample()
        {
            try
            {
                var request           = new HTTPrequest();
                List <ArtefactDto> vm = await request.Get <List <ArtefactDto> >("api/artefact?pageNumber=0&numPerPage=500&isDeleted=false");

                return(View(vm));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #30
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            try {
                var          request   = new HTTPrequest();
                StoreItemDto storeItem = await request.Get <StoreItemDto>("api/storeItem/" + id);

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

                return(RedirectToAction("Index", new { recentAction = "Deleted", recentName = storeItem.Name, recentId = storeItem.Id }));
            }
            catch (Exception) {
                throw;
            }
        }