private ProductTypeDTO Map(tblProductType tbl)
 {
     var dto = new ProductTypeDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.name,
                       Code = tbl.code,
                       Description = tbl.Description
                   };
     return dto;
 }
Example #2
0
 /// <summary>
 /// Create a new tblProductType object.
 /// </summary>
 /// <param name="id">Initial value of the id 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 tblProductType CreatetblProductType(global::System.Guid id, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status)
 {
     tblProductType tblProductType = new tblProductType();
     tblProductType.id = id;
     tblProductType.IM_DateCreated = iM_DateCreated;
     tblProductType.IM_DateLastUpdated = iM_DateLastUpdated;
     tblProductType.IM_Status = iM_Status;
     return tblProductType;
 }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tblProductType EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblProductType(tblProductType tblProductType)
 {
     base.AddObject("tblProductType", tblProductType);
 }
        private  tblProductType GetProductType(string productTypeName)
        {
            using (var ctx = new CokeDataContext(Con))
            {
                tblProductType productType = null;
                if (!string.IsNullOrEmpty(productTypeName))
                {
                    productType = ctx
                       .tblProductType.FirstOrDefault(
                           p =>
                           p.name.ToLower() == productTypeName.ToLower() ||
                           p.code != null &&
                           p.code.ToLower() == productTypeName.ToLower());
                }

                if (productType == null)
                {
                    productType = ctx.tblProductType.FirstOrDefault(p => p.name.ToLower() == "default");
                    if (productType == null)
                    {
                        productType = new tblProductType()
                                          {
                                              id = Guid.NewGuid(),
                                              name = string.IsNullOrEmpty(productTypeName) ? "default" : productTypeName,
                                              Description =
                                                  string.IsNullOrEmpty(productTypeName) ? "default" : productTypeName,
                                              code = string.IsNullOrEmpty(productTypeName) ? "default" : productTypeName,
                                              IM_DateCreated = DateTime.Now,
                                              IM_Status = (int) EntityStatus.Active,
                                              IM_DateLastUpdated = DateTime.Now
                                          };
                        ctx.tblProductType.AddObject(productType);
                        ctx.SaveChanges();
                    }

                }

                return productType;
            }
        }