コード例 #1
0
        public Band Update(Band band)
        {
            band.NameError       = "";
            band.RowVersionError = "";

            if (band.Name == "")
            {
                band.NameError = Errors.BandErrors.EmptyName;
                return(band);
            }

            var otherBand = GetByName(band.Name);

            if (otherBand != null && otherBand.ID != band.ID)
            {
                band.NameError = Errors.BandErrors.DuplicateName;
                return(band);
            }

            var success = bandsAccess.Update(LogicToDB(band));

            band = GetById(band.ID);

            if (!success)
            {
                band.RowVersionError = Errors.BandErrors.ConcurrencyError;
            }

            return(band);
        }
コード例 #2
0
        public void UpdateTest()
        {
            var band = bandsAccess.Get("")[0];

            band.Name          = "Music Band";
            band.Description   = "We play music.";
            band.InviteMessage = "Join us.";

            bandsAccess.Update(band);

            band = bandsAccess.Get("")[0];

            #region Assert
            Assert.AreEqual("Music Band", band.Name);
            Assert.AreEqual("We play music.", band.Description);
            Assert.AreEqual("Join us.", band.InviteMessage);
            #endregion
        }