private CommodityTypeDTO Map(tblCommodityType tbl) { var dto = new CommodityTypeDTO { 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; }
/// <summary> /// Deprecated Method for adding a new object to the tblCommodityType EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotblCommodityType(tblCommodityType tblCommodityType) { base.AddObject("tblCommodityType", tblCommodityType); }
/// <summary> /// Create a new tblCommodityType object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name 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 tblCommodityType CreatetblCommodityType(global::System.Guid id, global::System.String name, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status) { tblCommodityType tblCommodityType = new tblCommodityType(); tblCommodityType.Id = id; tblCommodityType.Name = name; tblCommodityType.IM_DateCreated = iM_DateCreated; tblCommodityType.IM_DateLastUpdated = iM_DateLastUpdated; tblCommodityType.IM_Status = iM_Status; return tblCommodityType; }
private tblCommodityType GetCommodityType(string name) { using (var ctx = new CokeDataContext(Con)) { tblCommodityType productType = null; if (!string.IsNullOrEmpty(name)) { productType = ctx .tblCommodityType.FirstOrDefault( p => p.Name.ToLower() == name.ToLower() || p.Code != null && p.Code.ToLower() == name.ToLower()); } if (productType == null) { productType = ctx.tblCommodityType.FirstOrDefault(p => p.Name.ToLower() == "default"); if (productType == null) { productType = new tblCommodityType() { Id = Guid.NewGuid(), Name = string.IsNullOrEmpty(name) ? "default" : name, Description = string.IsNullOrEmpty(name) ? "default" : name, Code = string.IsNullOrEmpty(name) ? "default" : name, IM_DateCreated = DateTime.Now, IM_Status = (int) EntityStatus.Active, IM_DateLastUpdated = DateTime.Now }; ctx.tblCommodityType.AddObject(productType); ctx.SaveChanges(); } } return productType; } }