/**
 * Takes an Int and returns an Exhibit[] with filled with the specific number of Exhibits
 */
    private static Exhibit[] getExhibits(int number, List <String> ids)
    {
        Exhibit[]     re = new Exhibit[number];
        List <String> id = ids;
        Exhibit       add;
        float         pos  = 1;
        int           name = 1;

        for (int i = 0; i < number; i++)
        {
            var exhibitToAdd = new Exhibit
            {
                path        = CineastUtils.GetImageUrlbyID(id[i]),
                name        = name.ToString(),
                position    = new Vector3(pos, 1.5f, 1),
                size        = new Vector3(1, 1, 1),
                id          = "" + i,
                type        = "IMAGE",
                light       = false,
                description = ""
            };
            pos += 1.5f;
            name++;
            re[i] = exhibitToAdd;
        }


        return(re);
    }
 public static void GenerateProperty(Exhibit exhibit)
 {
     var timeUnit = exhibit.TimeUnit.ToLower();
     if (timeUnit == "ga")
     {
         exhibit.x = -exhibit.Year.Value * 1000000000;
     }
     else if (timeUnit == "ma")
     {
         exhibit.x = -exhibit.Year.Value * 1000000;
     }
     else if (timeUnit == "ka")
     {
         exhibit.x = -exhibit.Year.Value * 1000;
     }
     else if (timeUnit == "bce")
     {
         exhibit.x = getCoordinateFromDMY(
             -exhibit.Year.Value,
             !exhibit.Month.HasValue ? 0 : Math.Min(11, Math.Max(0, exhibit.Month.Value - 1)),
             !exhibit.Day.HasValue ? 1 : exhibit.Day.Value
         );
     }
     else if (timeUnit == "ce")
     {
         exhibit.x = getCoordinateFromDMY(
             exhibit.Year.Value,
             !exhibit.Month.HasValue ? 0 : Math.Min(11, Math.Max(0, exhibit.Month.Value - 1)),
             !exhibit.Day.HasValue ? 1 : exhibit.Day.Value
         );
     }
 }
Exemple #3
0
        public DataSetMuseum getExhibit()
        {
            DataSetMuseum result     = new DataSetMuseum();
            Connection    connection = new Connection();

            connection.Open();
            try
            {
                Transaction transaction = connection.BeginTransaction();
                try
                {
                    exhibit = new Exhibit();
                    exhibit.Read(result, connection, transaction);
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    ShowError(ex.ToString());
                    transaction.Rollback();
                    result = null;
                }
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
Exemple #4
0
        public bool setExhibit(DataSetMuseum dataSet)
        {
            bool       result     = false;
            Connection connection = new Connection();

            connection.Open();
            try
            {
                Transaction transaction = connection.BeginTransaction();
                try
                {
                    exhibit = new Exhibit();
                    exhibit.Save(dataSet, connection, transaction);
                    transaction.Commit();
                    result = true;
                }
                catch (Exception ex)
                {
                    ShowError(ex.ToString());
                    transaction.Rollback();
                    result = false;
                }
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
Exemple #5
0
        public async Task <IActionResult> CreateExhibition([Bind("Artwork")] ProfileViewModel profileView, string Id)
        {
            var selected = Request.Form.Files[0];
            var category = Request.Form["category"];

            profileView.Artwork.Type      = category;
            profileView.Artwork.ImageFile = selected;
            profileView.Artwork.ImageName = selected.FileName;
            Member member = await MemberRepository.GetMember(Id);

            bool exist = ArtRepository.CheckIfIdExists(member);

            try
            {
                if (ModelState.IsValid)
                {
                    if (exist == true)
                    {
                        Exhibit exhibit = ArtRepository.GetExhibitId(member);
                        var     artwork = await ArtRepository.AddArtWithExistingExhibitId(_hostEnvironment, profileView.Artwork, member, exhibit);
                    }
                    else if (exist == false)
                    {
                        Exhibit exhibit = await ArtRepository.CreateExhibit(member);

                        var artwork = await ArtRepository.AddArt(_hostEnvironment, profileView.Artwork, member, exhibit);
                    }
                }
            }
            catch (Exception ex)
            {
                return(View("Error", ex));
            }
            return(Json(profileView.Artwork.ImageName));
        }
Exemple #6
0
        public void exhibit_should_allow_skydrive_content_item_adding()
        {
            var contentDocumentItemSkyDrive = new ContentItem
            {
                Title            = "ContentItemSkyDrive",
                Caption          = "This is skydrive",
                SkyDriveFileType = ContentItem.SkyDriveType.Document,
                Attribution      = "Tests Attribution",
                FileName         = "test document"
            };

            var contentPictureItemSkyDrive = new ContentItem
            {
                Title            = "ContentItemSkyDrive",
                Caption          = "This is skydrive",
                SkyDriveFileType = ContentItem.SkyDriveType.Image,
                Attribution      = "Tests Attribution",
                FileName         = "panda"
            };
            var exhibit = new Exhibit
            {
                Title        = "WebdriverExhibitWithContent",
                ContentItems = new Collection <Chronozoom.Entities.ContentItem> {
                    contentDocumentItemSkyDrive, contentPictureItemSkyDrive
                }
            };

            ExhibitHelper.AddExhibitWithSkyDriveContentItem(exhibit);
            _newExhibit = ExhibitHelper.GetNewExhibit();
            Assert.AreEqual(exhibit.ContentItems.Count, _newExhibit.ContentItems.Count, "Content items count are not equal");
            for (int i = 0; i < exhibit.ContentItems.Count; i++)
            {
                Assert.AreEqual(exhibit.ContentItems[i].Title, _newExhibit.ContentItems[i].Title, "Content items titles are not equal");
            }
        }
Exemple #7
0
        public async Task <IActionResult> CreateArt([Bind("Artwork")] ProfileViewModel profileView, string Id)
        {
            Member member = await MemberRepository.GetMember(Id);

            Exhibit exhibit = null;

            var selected = Request.Form.Files[0];
            var category = Request.Form["category"];

            profileView.Artwork.ImageFile = selected;
            profileView.Artwork.Type      = category;

            try
            {
                if (ModelState.IsValid)
                {
                    var artwork = await ArtRepository.AddArt(_hostEnvironment, profileView.Artwork, member, exhibit);
                }
            }
            catch (Exception ex)
            {
                return(View("Error", ex));
            }
            return(RedirectToAction($"Index", new { Id }));
        }
Exemple #8
0
 public void ChangeExhibit(Exhibit exh)      // уже изменённый
 {
     Console.Write("Меняю..." + "\n");
     exh.SendExhibit();
     Console.Write("Сменил." + "\n");
     // true/false
 }
Exemple #9
0
        public ActionResult Create(ExhibitCreateViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", new ExhibitCreateViewModel()
                {
                    ExhibitTypes = _query.GetExhibitTypes()
                }));
            }

            var exhibit = new Exhibit()
            {
                Name        = viewModel.Name,
                Description = viewModel.Description,
                Created     = viewModel.GetCreated(),
                TypeId      = viewModel.ExhibitType
            };



            _command.Create(exhibit);


            return(RedirectToAction("Index"));
        }
Exemple #10
0
        public ActionResult Delete(int exhibitID)
        {
            Exhibit deletedExibit = repository.DeleteExhibit(exhibitID);

            TempData["message"] = string.Format("{0} удален.", deletedExibit.Name);
            return(RedirectToAction("Index"));
        }
        public void PostExhibit([FromBody] Exhibit exhibit)
        {
            string commandText = "INSERT INTO tblExhibits(ExhibitName, ExhibitDesc, CollectionID, ExhibitLat, ExhibitLong, BeaconID) VALUES (@Name, @Desc, @ColID, @Lat, @Long, @BeaconID)";

            SqlCommand cmd = new SqlCommand(commandText, conn);

            cmd.Parameters.Add("@Name", SqlDbType.VarChar);
            cmd.Parameters["@Name"].Value = exhibit.ExhibitName;
            cmd.Parameters.Add("@Desc", SqlDbType.VarChar);
            cmd.Parameters["@Desc"].Value = exhibit.ExhibitDesc;
            cmd.Parameters.Add("@ColID", SqlDbType.Int);
            cmd.Parameters["@ColID"].Value = exhibit.CollectionID;
            cmd.Parameters.Add("@Lat", SqlDbType.Decimal);
            cmd.Parameters["@Lat"].Value = exhibit.ExhibitLat;
            cmd.Parameters.Add("@Long", SqlDbType.Decimal);
            cmd.Parameters["@Long"].Value = exhibit.ExhibitLong;
            cmd.Parameters.Add("@BeaconID", SqlDbType.Int);
            cmd.Parameters["@BeaconID"].Value = exhibit.BeaconID;


            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                throw;
            }
        }
        public async Task Should_return_all_exhibits()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = "aperture gallery",
                DateTime = DateTime.Today,
                ImageUrl = "url"
            };

            var exhibit = Exhibit.Create(exhibitCommand);

            var attendanceCommand = new Attend.Command
            {
                UserId    = _attendeeId,
                ExhibitId = _exhibitId
            };

            var attendance = Attendance.Create(attendanceCommand);

            exhibit.AddAttendance(attendance);

            await InsertAsync(exhibit);

            var result = await SendAsync(new Index.Query());

            result.ShouldNotBeNull();
        }
Exemple #13
0
 public void NavigateToExhibit(Exhibit exhibit)
 {
     Logger.Log("<- title: " + exhibit.Title);
     ExecuteJavaScript(string.Format("CZ.Search.goToSearchResult('e{0}')", exhibit.Id));
     WaitAnimation();
     Logger.Log("->");
 }
 /// <summary>
 /// Figures out which position in the list the current member is located, and then sets the previous and next Id's
 /// </summary>
 /// <param name="exhibit"></param>
 /// <param name="exhibits"></param>
 public void SetShowroomPositionsInList(Exhibit exhibit, List <Exhibit> exhibits)
 {
     for (int i = 0; i < exhibits.Count; i++)
     {
         if (exhibit.Id == exhibits[i].Id)
         {
             if (i == 0)
             {
                 PositionInList = i;
                 PreviousInList = exhibits.Count - 1;
                 NextInList     = 1;
             }
             else if (i == exhibits.Count - 1)
             {
                 PositionInList = i;
                 PreviousInList = i - 1;
                 NextInList     = 0;
             }
             else
             {
                 PositionInList = i;
                 PreviousInList = PositionInList - 1;
                 NextInList     = PositionInList + 1;
             }
         }
     }
     if (exhibits.Count <= 1)
     {
         NextInList     = 0;
         PreviousInList = 0;
     }
 }
Exemple #15
0
        public async Task <Exhibit> Create(Exhibit toCreate)
        {
            toCreate.Id = (Guid?)new Guid();
            await Task.Run(() => Exhibits.Add(toCreate));

            return(toCreate);
        }
Exemple #16
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            if (savedInstanceState != null)
            {
                e = ExhibitManager.GetExhibit(savedInstanceState.GetString(Data));
            }


            var alert = new AlertDialog.Builder(Activity);

            alert.SetTitle(Resources.GetString(Resource.String.exhibit_is__near_title));
            alert.SetMessage($"{Activity.Resources.GetString (Resource.String.exhibit_is_near1)} \"{e.Name}\" {Activity.Resources.GetString (Resource.String.exhibit_is_near2)}");
            alert.SetPositiveButton(Resource.String.exhibit_open_yes, (senderAlert, args) => {
                var intent   = new Intent(Activity, typeof(ExhibitDetailsActivity));
                var pageList = e.Pages;
                if ((pageList == null) || !pageList.Any())
                {
                    Toast.MakeText(Activity,
                                   Activity.GetString(Resource.String.currently_no_further_info),
                                   ToastLength.Short).Show();
                }
                else
                {
                    intent.PutExtra(ExhibitDetailsActivity.INTENT_EXTRA_EXHIBIT_ID, e.Id);
                    Activity.StartActivity(intent);
                }
            });

            alert.SetNegativeButton(Resource.String.exhibit_open_no, (senderAlert, args) => { ExtendedLocationListener.GetInstance().EnableCheckForExhibits(); });

            return(alert.Create());
        }
        public Exhibit GetNewExhibit()
        {
            Logger.Log("<-");
            const string script      = Javascripts.LastCanvasElement;
            var          exhibit     = new Exhibit();
            var          contentItem = new ContentItem();

            exhibit.ContentItems = new Collection <Chronozoom.Entities.ContentItem>();
            exhibit.Title        = GetJavaScriptExecutionResult(script + ".title");
            int contentItemsCount = int.Parse(GetJavaScriptExecutionResult(script + ".contentItems.length"));

            Logger.Log("- contentItemsCount: " + contentItemsCount);
            for (int i = 0; i < contentItemsCount; i++)
            {
                string item = string.Format("{0}.contentItems[{1}].", script, i);
                contentItem.Title = GetJavaScriptExecutionResult(item + "title");
                Logger.Log("- contentItem.Title: " + contentItem.Title);
                contentItem.Caption = GetJavaScriptExecutionResult(item + "description");
                Logger.Log("- contentItem.Caption: " + contentItem.Caption);
                contentItem.Uri = GetJavaScriptExecutionResult(item + "uri");
                Logger.Log("- contentItem.MediaSource: " + contentItem.MediaSource);
                contentItem.MediaType = GetJavaScriptExecutionResult(item + "mediaType");
                Logger.Log("- contentItem.MediaType: " + contentItem.MediaType);
                contentItem.MediaSource = GetJavaScriptExecutionResult(item + "mediaSource");
                Logger.Log("- contentItem.MediaSource: " + contentItem.MediaSource);
                contentItem.Attribution = GetJavaScriptExecutionResult(item + "attribution");
                Logger.Log("- contentItem.attribution: " + contentItem.Attribution);
                exhibit.ContentItems.Add(contentItem);
            }
            exhibit.Id = new Guid(GetJavaScriptExecutionResult(script + ".guid"));
            Logger.Log("- exhibit.Id: " + exhibit.Id);
            Logger.Log("->" + exhibit);
            return(exhibit);
        }
Exemple #18
0
        public void TestInitialize()
        {
            BrowserStateManager.RefreshState();
            HomePageHelper.OpenSandboxPage();
            //HomePageHelper.DeleteAllElementsLocally();
            TourHelper.DeleteToursIfExist("webdriverTour");

            #region create timeline

            _newTimeline = new Timeline
            {
                FromYear = -6061670000,
                ToYear   = -5808809999,
                Title    = "WebDriverApiTitle"
            };
            Guid newTimelineId = ApiHelper.CreateTimelineByApi(_newTimeline);
            _newTimeline.Id = newTimelineId;

            #endregion

            #region create exhibit

            var contentItems = new Collection <ContentItem>();
            var contentItem  = new ContentItem()
            {
                Title = "WebDriverApi", MediaType = "image", Uri = @"http://yandex.st/www/1.609/yaru/i/logo.png", Caption = "", Order = 0, Attribution = "", MediaSource = ""
            };
            contentItems.Add(contentItem);

            _newExhibit = new Exhibit()
            {
                Timeline_ID  = newTimelineId,
                Title        = "WebDriverApiExhibit",
                Year         = -8596430000,
                ContentItems = contentItems
            };
            _newExhibit.Id = new Guid(ApiHelper.CreateExhibitByApi(_newExhibit).ExhibitId);

            #endregion

            #region init new tour

            _newTour             = new Tour();
            _newTour.Name        = "webdriverTour";
            _newTour.Description = "webdriver description";
            Bookmark exhibitBookmark = new Bookmark {
                Name = "WebDriverApiExhibitBookmark", Id = _newExhibit.Id, Type = "exhibit"
            };
            Bookmark timelineBookmark = new Bookmark {
                Name = "WebDriverApiTimelineBookmark", Id = _newTimeline.Id, Type = "timeline"
            };
            Collection <Chronozoom.Entities.Bookmark> bookmarks = new Collection <Chronozoom.Entities.Bookmark> {
                exhibitBookmark, timelineBookmark
            };
            _newTour.Bookmarks = bookmarks;

            #endregion

            HomePageHelper.OpenSandboxPage();
        }
        public async Task <int> DeleteExhibit(int id)
        {
            Exhibit exhibit = _unitOfWork.Repository <Exhibit>().GetById(id);

            if (exhibit == null)
            {
                throw new Exception("Cant Not Found This Exhibit!");
            }
            if (exhibit.Status == (int)ExhibitsStatus.Status.Ready)
            {
                try
                {
                    exhibit.IsDelete = true;
                    await _unitOfWork.CommitAsync();
                }
                catch (Exception)
                {
                    throw new Exception("Can not delete exhibit!!!");
                }
            }
            else if (exhibit.Status == (int)ExhibitsStatus.Status.Added)
            {
                throw new Exception("Can not delete exhibit!!!");
            }
            return(exhibit.Id);
        }
Exemple #20
0
        internal async Task <Exhibit> AddExhibit(Exhibit exhibitToAdd)
        {
            Exhibit created = await _exhibitRepository.Create(exhibitToAdd);

            Exhibits.Add(created);
            return(created);
        }
Exemple #21
0
        public void exhibit_should_allow_two_content_items_adding()
        {
            var contentItemImage = new ContentItem
            {
                Title     = "ContentItemImage",
                MediaType = "Image",
                Uri       = "http://i.telegraph.co.uk/multimedia/archive/02429/eleanor_scriven_2429776k.jpg"
            };
            var contentItemMusic = new ContentItem
            {
                Title     = "ContentItemMusic",
                MediaType = "Audio",
                Uri       = "http://libsyn.com/media/eslpod/ESLPod900.mp3"
            };
            var exhibit = new Exhibit
            {
                Title        = "WebdriverExhibitWithContent",
                ContentItems = new Collection <Chronozoom.Entities.ContentItem> {
                    contentItemImage, contentItemMusic
                }
            };

            ExhibitHelper.AddExhibitWithContentItem(exhibit);
            _newExhibit = ExhibitHelper.GetNewExhibit();
            Assert.AreEqual(exhibit.ContentItems.Count, _newExhibit.ContentItems.Count, "Content items count are not equal");
            for (int i = 0; i < exhibit.ContentItems.Count; i++)
            {
                Assert.AreEqual(exhibit.ContentItems[i].Title, _newExhibit.ContentItems[i].Title, "Content items titles are not equal");
                Assert.AreEqual(exhibit.ContentItems[i].MediaType, _newExhibit.ContentItems[i].MediaType, true, "Content items mediaTypes are not equal");
                Assert.AreEqual(exhibit.ContentItems[i].Uri, _newExhibit.ContentItems[i].Uri, "Content items Uri are not equal");
            }
        }
        /// <summary>
        /// Build and persist a new <see cref="Exhibit"/>.
        /// </summary>
        /// <param name="exhibit">A new <see cref="Exhibit"/></param>
        /// <returns>The persisted <see cref="Exhibit"/>.</returns>
        public Exhibit CreateExhibit(Exhibit exhibit)
        {
            this._persistence.GetRepository <Exhibit>().Add(exhibit);
            this._persistence.Commit();

            return(exhibit);
        }
        public void EditExhibit(int id, [FromBody] Exhibit exhibit)
        {
            string commandText = "UPDATE tblExhibits SET ExhibitName = @name, ExhibitDesc = @desc, CollectionID = @ColID, ExhibitLat = @Lat, ExhibitLong = @Long, BeaconID = @BeaconID";


            SqlCommand cmd = new SqlCommand(commandText, conn);

            cmd.Parameters.Add("@Name", SqlDbType.VarChar);
            cmd.Parameters["@Name"].Value = exhibit.ExhibitName;
            cmd.Parameters.Add("@Desc", SqlDbType.VarChar);
            cmd.Parameters["@Desc"].Value = exhibit.ExhibitDesc;
            cmd.Parameters.Add("@ColID", SqlDbType.Int);
            cmd.Parameters["@ColID"].Value = exhibit.CollectionID;
            cmd.Parameters.Add("@Lat", SqlDbType.Decimal);
            cmd.Parameters["@Lat"].Value = exhibit.ExhibitLat;
            cmd.Parameters.Add("@Long", SqlDbType.Decimal);
            cmd.Parameters["@Long"].Value = exhibit.ExhibitLong;
            cmd.Parameters.Add("@BeaconID", SqlDbType.Int);
            cmd.Parameters["@BeaconID"].Value = exhibit.BeaconID;


            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                throw;
            }
        }
Exemple #24
0
        public void NotifyUser()
        {
            var exhibitCommand = new Create.Command
            {
                GenreId  = 1,
                UserId   = "id",
                Location = "aperture gallery",
                DateTime = DateTime.Today,
                ImageUrl = "url"
            };
            var exhibit = Exhibit.Create(exhibitCommand);

            var user = new ApplicationUser
            {
                Email    = _testUsername,
                Name     = _testName,
                ImageUrl = _testImageUrl
            };

            var notification = Notification.ExhibitCreated(exhibit);

            user.Notify(notification);
            var userNotification = user.UserNotifications.SingleOrDefault();

            Assert.Equal(_testName, userNotification.User.Name);
        }
        /// <summary>
        /// Build and persist a new <see cref="Exhibit"/>.
        /// </summary>
        /// <param name="exhibit">A new <see cref="Exhibit"/></param>
        /// <returns>The persisted <see cref="Exhibit"/>.</returns>
        public Exhibit CreateExhibit(Exhibit exhibit)
        {
            this._persistence.GetRepository<Exhibit>().Add(exhibit);
            this._persistence.Commit();

            return exhibit;
        }
Exemple #26
0
        public bool OnInterceptTouchEvent(RecyclerView view, MotionEvent e)
        {
            var childView = view.FindChildViewUnder(e.GetX(), e.GetY());

            if (childView != null && gestureDetector.OnTouchEvent(e))
            {
                var intent = new Intent(mainActivity, typeof(ExhibitDetailsActivity));

                Exhibit exhibit = null;
                for (var i = 0; i < exhibitSet.ActiveSet.Count; ++i)
                {
                    exhibit = exhibitSet.ActiveSet [i];
                    if (exhibit.Id == childView.ContentDescription)
                    {
                        break;
                    }
                }

                if (exhibit != null)
                {
                    var pageList = exhibit.Pages;
                    if (pageList == null || !pageList.Any())
                    {
                        Toast.MakeText(mainActivity,
                                       mainActivity.GetString(Resource.String.currently_no_further_info),
                                       ToastLength.Short)
                        .Show();
                        return(false);
                    }
                    intent.PutExtra(ExhibitDetailsActivity.INTENT_EXTRA_EXHIBIT_ID, exhibit.Id);
                    ActivityCompat.StartActivity(mainActivity, intent, null);
                }
            }
            return(false);
        }
Exemple #27
0
        internal async Task <Exhibit> AddExhibit(Exhibit exhibitToAdd)
        {
            Location locationToAdd = GetLocationToAdd(exhibitToAdd);
            Exhibit  created       = await locationToAdd.AddExhibit(exhibitToAdd);

            return(created);
        }
Exemple #28
0
        public void exhibit_should_allow_pdf_content_item_adding()
        {
            Logger.Log("Bug: https://github.com/alterm4nn/ChronoZoom/issues/526", LogType.Debug);
            var contentItemPdf = new ContentItem
            {
                Title       = "ContentItemPdf",
                Caption     = "This is pdf",
                MediaSource = "http://ads.ccsd.cnrs.fr/docs/00/10/47/81/PDF/p85_89_vol3483m.pdf",
                MediaType   = "PDF",
                Attribution = "Tests Attribution",
                Uri         = "http://ads.ccsd.cnrs.fr/docs/00/10/47/81/PDF/p85_89_vol3483m.pdf"
            };
            var exhibit = new Exhibit
            {
                Title        = "WebdriverExhibitWithContent",
                ContentItems = new Collection <Chronozoom.Entities.ContentItem> {
                    contentItemPdf
                }
            };

            ExhibitHelper.AddExhibitWithContentItem(exhibit);
            _newExhibit = ExhibitHelper.GetNewExhibit();
            Assert.AreEqual(exhibit.ContentItems.Count, _newExhibit.ContentItems.Count, "Content items count are not equal");
            for (int i = 0; i < exhibit.ContentItems.Count; i++)
            {
                Assert.AreEqual(exhibit.ContentItems[i].Title, _newExhibit.ContentItems[i].Title, "Content items titles are not equal");
                Assert.AreEqual(exhibit.ContentItems[i].MediaType, _newExhibit.ContentItems[i].MediaType, true, "Content items mediaTypes are not equal");
                Assert.AreEqual(exhibit.ContentItems[i].Uri, _newExhibit.ContentItems[i].Uri, "Content items Uri are not equal");
            }
        }
Exemple #29
0
        // GET: Info
        public ViewResult Info(int exhibitID)
        {
            TempData["returnUrl"] = Request.ServerVariables["HTTP_REFERER"];
            Exhibit exhibit = repository.Exhibits.FirstOrDefault(p => p.ExhibitID == exhibitID);

            return(View(exhibit));
        }
        public ActionResult Create(FormCollection data)
        {
            if (ModelState.IsValid)
            {
                Exhibit ex = new Exhibit
                {
                    Name     = data["Name"],
                    Date     = Convert.ToDateTime(data["Date"]),
                    Location = data["Location"],
                    ArtKeys  = data["Selects"],
                    Gallery  = ArtsDb.GetArtsByString(db, data["Selects"])
                };

                if (!ExhibitsDb.HasExhibit(db, ex.Name))
                {
                    db.DbExhibit.Add(ex);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("Name", "This name has been used already.");
                }
            }

            return(View(data));
        }
        public async Task <int> UpdateExhibit(int id, string Name, string Description, string NameEng, string DescriptionEng, string Image, TimeSpan Duration)
        {
            var listExhibits = _unitOfWork.Repository <Exhibit>().GetAll().Where(e => e.Id != id &&
                                                                                 (e.IsDelete != true) &&
                                                                                 (e.Name.Equals(Name) || e.NameEng.Equals(NameEng))
                                                                                 ).ToList();

            if (listExhibits.Count() > 0)
            {
                throw new Exception("Tên tiếng Việt hoặc tên tiếng Anh của hiện vật này đã bị trùng với hiện vật khác!!!");
            }


            Exhibit exhibit = _unitOfWork.Repository <Exhibit>().GetById(id);

            try
            {
                exhibit.Name           = Name;
                exhibit.Description    = Description;
                exhibit.NameEng        = NameEng;
                exhibit.DescriptionEng = DescriptionEng;
                exhibit.Image          = Image;
                exhibit.Duration       = Duration;

                await _unitOfWork.CommitAsync();

                return(exhibit.Id);
            }
            catch (Exception)
            {
                throw new Exception("Update Error!!!");
            }
        }
        private static string ComputeScoreString(Exhibit exhibit)
        {
            var score          = Settings.ExhibitScores.ScoreFor(exhibit) ?? 0;
            var totalQuestions = DbManager.DataAccess.Quizzes().QuizzesForExhibit(exhibit.Id).Count();

            return($"{score}/{totalQuestions}");
        }
        /// <summary>
        /// Retrieve an <see cref="AudioFile"/>.
        /// </summary>
        /// <param name="exhibit">The <see cref="Exhibit"/> to get the audio file for.</param>
        /// <param name="knowledgeLevel">The <see cref="KnowledgeLevel"/> of the <see cref="Customer"/> so they get the right <see cref="AudioFile"/>.</param>
        /// <param name="language">The <see cref="Language"/> of the <see cref="Customer"/> so they get the right <see cref="AudioFile"/>.</param>
        /// <returns>An <see cref="AudioFile"/> that corresponds to the given information.</returns>
        public AudioFile GetFile(Exhibit exhibit, KnowledgeLevel knowledgeLevel, Language language)
        {
            var file =
                this._persistence.GetRepository<AudioFile>()
                    .Single(
                        af =>
                            af.Exhibit.Id == exhibit.Id
                            && af.KnowledgeLevel.Id == knowledgeLevel.Id
                            && af.Language.Id == language.Id);

            if (file == null || file.FilePath == null)
            {
                return null;
            }

            file.FilePath = Path.Combine(ConfigurationManager.AppSettings["RemoteAudioFilePath"], file.FilePath);

            return file;
        }
        public ActionResult AddExhibit(Exhibit exhibit)
        {
            this._exhibitService.CreateExhibit(exhibit);

            return this.RedirectToAction("Index", "Exhibit");
        }