Exemplo n.º 1
0
        public EventEdit(ReleaseEventDetailsContract contract)
            : this()
        {
            ParamIs.NotNull(() => contract);

            Date = contract.Date;
            Description = contract.Description;
            Id = contract.Id;
            Name = contract.Name;
            SeriesNumber = contract.SeriesNumber;

            CopyNonEditableProperties(contract);
        }
Exemplo n.º 2
0
		public void Create_NoSeries() {
			
			var contract = new ReleaseEventDetailsContract {
				Description = string.Empty,
				Name = "Vocaloid Paradise",
			};

			var result = CallUpdate(contract);

			Assert.IsTrue(repository.Contains(result), "Event was saved to repository");
			Assert.AreEqual("Vocaloid Paradise", result.Name, "Name");
			Assert.IsNull(result.Series, "Series");

		}
Exemplo n.º 3
0
		public void Create_WithSeriesAndSuffix() {

			
			var contract = new ReleaseEventDetailsContract {
				Description = string.Empty,
				Series = new ReleaseEventSeriesContract(series),
				SeriesNumber = 2014,
				SeriesSuffix = "Spring",
			};

			var result = CallUpdate(contract);

			Assert.IsTrue(repository.Contains(result), "Event was saved to repository");
			Assert.AreEqual("M3 2014 Spring", result.Name, "Name");
			Assert.AreEqual(2014, result.SeriesNumber, "SeriesNumber");
			Assert.AreEqual("Spring", result.SeriesSuffix, "SeriesSuffix");
			Assert.AreSame(series, result.Series, "Series");

		}
Exemplo n.º 4
0
        public void CopyNonEditableProperties(ReleaseEventDetailsContract contract)
        {
            ParamIs.NotNull(() => contract);

            AllSeries = contract.AllSeries;

            CopyNonEditableProperties(contract.Series);
        }
Exemplo n.º 5
0
        public ActionResult Find(ReleaseEventFindResultContract model, string query, string EventTarget)
        {
            bool skipSeries = false;

            if (EventTarget != "Series") {

                skipSeries = true;

                if (string.IsNullOrEmpty(model.EventName))
                    ModelState.AddModelError("EventName", "Name must be specified");

            }

            if (!ModelState.IsValid) {
                return View(model);
            }

            var contract = new ReleaseEventDetailsContract { Name = model.EventName, Series = (skipSeries ? null : model.Series), SeriesNumber = model.SeriesNumber };

            var ev = Service.UpdateEvent(contract);

            if (query != ev.Name)
                Services.Albums.UpdateAllReleaseEventNames(query, ev.Name);

            return RedirectToAction("Edit", new { id = ev.Id });
        }
Exemplo n.º 6
0
		private ReleaseEvent CallUpdate(ReleaseEventDetailsContract contract) {
			
			var result = queries.Update(contract);
			return repository.Load(result.Id);

		}
Exemplo n.º 7
0
		public void Update_ChangeSeriesSuffix() {
			
			var contract = new ReleaseEventDetailsContract(existingEvent, ContentLanguagePreference.Default);
			contract.SeriesSuffix = "Fall";

			var result = CallUpdate(contract);

			Assert.AreEqual(2013, contract.SeriesNumber, "SeriesNumber");
			Assert.AreEqual("Fall", contract.SeriesSuffix, "SeriesSuffix");
			Assert.AreEqual("M3 2013 Fall", result.Name, "Name");
			Assert.AreEqual("M3 2013 Fall", album.OriginalReleaseEventName, "OriginalReleaseEventName for album");

		}
Exemplo n.º 8
0
        public ActionResult Find(ReleaseEventFindResultContract model, string query, string EventTarget)
        {
            bool skipSeries = false;

            if (EventTarget != "Series") {

                skipSeries = true;

                if (string.IsNullOrEmpty(model.EventName))
                    ModelState.AddModelError("EventName", "Name must be specified");

            }

            if (!ModelState.IsValid) {
                return View(model);
            }

            var contract = new ReleaseEventDetailsContract {
                Name = model.EventName,
                Series = (skipSeries ? null : model.Series),
                SeriesNumber = model.SeriesNumber,
                SeriesSuffix = string.Empty	// TODO: add support for entering this
            };

            var ev = queries.Update(contract);

            return RedirectToAction("Edit", new { id = ev.Id });
        }
Exemplo n.º 9
0
        public ReleaseEventContract UpdateEvent(ReleaseEventDetailsContract contract)
        {
            ParamIs.NotNull(() => contract);

            PermissionContext.VerifyPermission(PermissionToken.ManageDatabase);

            return HandleTransaction(session => {

                ReleaseEvent ev;

                if (contract.Id == 0) {

                    if (contract.Series != null) {
                        var series = session.Load<ReleaseEventSeries>(contract.Series.Id);
                        ev = new ReleaseEvent(contract.Description, contract.Date, series, contract.SeriesNumber);
                        series.Events.Add(ev);
                    } else {
                        ev = new ReleaseEvent(contract.Description, contract.Date, contract.Name);
                    }

                    session.Save(ev);

                    Archive(session, ev, new ReleaseEventDiff(), EntryEditEvent.Created);

                    AuditLog("created " + ev, session);

                } else {

                    ev = session.Load<ReleaseEvent>(contract.Id);
                    var diff = new ReleaseEventDiff();

                    if (ev.Date != contract.Date)
                        diff.Date = true;

                    if (ev.Description != contract.Description)
                        diff.Description = true;

                    if (ev.Name != contract.Name)
                        diff.Name = true;

                    if (ev.SeriesNumber != contract.SeriesNumber)
                        diff.SeriesNumber = true;

                    ev.Date = contract.Date;
                    ev.Description = contract.Description;
                    ev.Name = contract.Name;
                    ev.SeriesNumber = contract.SeriesNumber;

                    session.Update(ev);

                    Archive(session, ev, diff, EntryEditEvent.Updated);

                    var logStr = string.Format("updated properties for {0} ({1})", CreateEntryLink(ev), diff.ChangedFieldsString);
                    AuditLog(logStr, session);

                }

                return new ReleaseEventContract(ev);

            });
        }