public void IsValid()
 {
     var item = new ReputationDto()
     {
         Name = Guid.NewGuid().ToString(),
     };
     Assert.IsTrue(item.IsValid());
 }
 public void IsInvalid()
 {
     var item = new ReputationDto()
     {
         Name = string.Empty,
     };
     Assert.IsFalse(item.IsValid());
 }
 /// <summary>
 /// Create the specified item into the database
 /// </summary>
 /// <param name="reputation">The item to add in the database</param>
 public long Create(ReputationDto reputation)
 {
     return new Creator(this.Session).Create(reputation);
 }
 public static void SetReputation(DependencyObject target, ReputationDto value)
 {
     target.SetValue(ReputationProperty, value);
 }
 /// <summary>
 /// Updates the specified reputation.
 /// </summary>
 /// <param name="reputation">The tag.</param>
 public void Update(ReputationDto reputation)
 {
     new Updator(this.Session).Update(reputation);
 }
        public void Remove(ReputationDto item)
        {
            var remover = new Remover(this.Session);

            if (remover.CanRemove(item)) { remover.Remove<Reputation>(item); }
        }
 /// <summary>
 /// Determines whether this instance can remove the specified reputation dto.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>
 ///   <c>true</c> if this instance can remove the specified reputation dto; otherwise, <c>false</c>.
 /// </returns>
 public bool CanRemove(ReputationDto item)
 {
     return new Remover(this.Session).CanRemove(item);
 }
Beispiel #8
0
        /// <summary>
        /// Create the specified item into the database
        /// </summary>
        /// <param name="item">The item to add in the database</param>
        public long Create(ReputationDto item)
        {
            Assert.IsNotNull(item, "item");

            var exist = (from p in this.Session.Query<Reputation>()
                         where item.Name.ToUpper() == p.Name.ToUpper()
                         || p.Id == item.Id
                         select p).ToList().Count() > 0;
            if (exist) throw new ExistingItemException();

            var entity = Mapper.Map<ReputationDto, Reputation>(item);

            item.Id = (long)this.Session.Save(entity);
            return item.Id;
        }