コード例 #1
0
 public void IsValid()
 {
     var item = new InsuranceDto()
     {
         Name = Guid.NewGuid().ToString(),
     };
     Assert.IsTrue(item.IsValid());
 }
コード例 #2
0
 public void IsInvalid()
 {
     var item = new InsuranceDto()
     {
         Name = string.Empty,
     };
     Assert.IsFalse(item.IsValid());
 }
コード例 #3
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 insurance)
 {
     return new Creator(this.Session).Create(insurance);
 }
コード例 #4
0
 public static void SetInsurance(DependencyObject target, InsuranceDto value)
 {
     target.SetValue(InsuranceProperty, value);
 }
コード例 #5
0
 /// <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);
 }
コード例 #6
0
 /// <summary>
 /// Updates the specified insurance.
 /// </summary>
 /// <param name="insurance">The drug.</param>
 public void Update(InsuranceDto insurance)
 {
     new Updator(this.Session).Update(insurance);
 }
コード例 #7
0
 /// <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);
 }
コード例 #8
0
ファイル: Creator.cs プロジェクト: seniorOtaka/ndoctor
        /// <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;
        }