Esempio n. 1
0
 public void IsValid()
 {
     var item = new InsuranceDto()
     {
         Name = Guid.NewGuid().ToString(),
     };
     Assert.IsTrue(item.IsValid());
 }
Esempio n. 2
0
 public void IsInvalid()
 {
     var item = new InsuranceDto()
     {
         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(InsuranceDto insurance)
 {
     return new Creator(this.Session).Create(insurance);
 }
Esempio n. 4
0
 public static void SetInsurance(DependencyObject target, InsuranceDto value)
 {
     target.SetValue(InsuranceProperty, value);
 }
 /// <summary>
 /// Determines whether the specified item can be removed.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>
 ///   <c>true</c> if this instance can remove the specified item; otherwise, <c>false</c>.
 /// </returns>
 public bool CanRemove(InsuranceDto item)
 {
     return new Remover(this.Session).CanRemove(item);
 }
 /// <summary>
 /// Updates the specified insurance.
 /// </summary>
 /// <param name="insurance">The drug.</param>
 public void Update(InsuranceDto insurance)
 {
     new Updator(this.Session).Update(insurance);
 }
 /// <summary>
 /// Removes item with the specified id.
 /// </summary>
 /// <typeparam name="T">The type of the item to remove</typeparam>
 /// <param name="id">The id of the item to remove.</param>
 public void Remove(InsuranceDto item)
 {
     new Remover(this.Session).Remove(item);
 }
Esempio n. 8
0
        /// <summary>
        /// Create the specified item into the database
        /// </summary>
        /// <param name="reputation">The item to add in the database</param>
        public long Create(InsuranceDto item)
        {
            Assert.IsNotNull(item, "item");

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

            var entity = Mapper.Map<InsuranceDto, Insurance>(item);

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