コード例 #1
0
 private VATClassDTO Map(tblVATClass tbl)
 {
     var dto = new VATClassDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.Name,
                       VatClass = tbl.Class,
                       VatClassItems = new List<VatClassItemDTO>()
                   };
     foreach (var item in tbl.tblVATClassItem.Where(n => n.IM_Status== (int)EntityStatus.Active))
     {
         var dtoitem = new VatClassItemDTO
                           {
                               MasterId = item.id,
                               DateCreated = item.IM_DateCreated,
                               DateLastUpdated = item.IM_DateLastUpdated,
                               StatusId = item.IM_Status,
                               Rate = item.Rate,
                               EffectiveDate = item.EffectiveDate,
                               VatClassMasterId = item.VATClassID,
                           };
         dto.VatClassItems.Add(dtoitem);
     }
     return dto;
 }
コード例 #2
0
 /// <summary>
 /// Create a new tblVATClass object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="class">Initial value of the Class property.</param>
 /// <param name="iM_DateCreated">Initial value of the IM_DateCreated property.</param>
 /// <param name="iM_DateLastUpdated">Initial value of the IM_DateLastUpdated property.</param>
 /// <param name="iM_Status">Initial value of the IM_Status property.</param>
 public static tblVATClass CreatetblVATClass(global::System.Guid id, global::System.String name, global::System.String @class, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status)
 {
     tblVATClass tblVATClass = new tblVATClass();
     tblVATClass.id = id;
     tblVATClass.Name = name;
     tblVATClass.Class = @class;
     tblVATClass.IM_DateCreated = iM_DateCreated;
     tblVATClass.IM_DateLastUpdated = iM_DateLastUpdated;
     tblVATClass.IM_Status = iM_Status;
     return tblVATClass;
 }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tblVATClass EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblVATClass(tblVATClass tblVATClass)
 {
     base.AddObject("tblVATClass", tblVATClass);
 }
コード例 #4
0
        private tblVATClass GetVATClass(string vatNameCode)
        {
            using (var ctx = new CokeDataContext(Con))
            {
                tblVATClass vatClass = null;
                if (!string.IsNullOrEmpty(vatNameCode))
                {
                    vatClass = ctx
                        .tblVATClass.FirstOrDefault(
                            p => p.Class != null &&
                                 p.Class.ToLower() == vatNameCode.ToLower() ||
                                 p.Name != null && p.Name.ToLower() == vatNameCode.ToLower());
                }
                //if (vatClass == null)
                //    vatClass = ctx.tblVATClass.FirstOrDefault(p => p.Class == "default");

                if (vatClass == null)
                {
                    return null;
                    var item = new tblVATClass()
                                   {
                                       Class = "default",
                                       Name = "default",
                                       id = Guid.NewGuid(),
                                       IM_DateCreated = DateTime.Now,

                                       IM_DateLastUpdated = DateTime.Now,
                                       IM_Status = (int) EntityStatus.Active,
                                       tblVATClassItem = new EntityCollection<tblVATClassItem>()
                                                             {
                                                                 new tblVATClassItem()
                                                                     {
                                                                         id = Guid.NewGuid(),
                                                                         Rate = 0m,
                                                                         EffectiveDate = DateTime.Now,
                                                                         IM_DateCreated = DateTime.Now,
                                                                         IM_DateLastUpdated = DateTime.Now,
                                                                         IM_Status = (int) EntityStatus.Active
                                                                     }
                                                             }
                                   };

                    ctx.tblVATClass.AddObject(item);
                    ctx.SaveChanges();
                }
                return vatClass;
            }
        }