private OutletTypeDTO Map(tblOutletType tbl)
 {
     var dto = new OutletTypeDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.Name,
                       Code = tbl.Code
                   };
     return dto;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the tblOutletType EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblOutletType(tblOutletType tblOutletType)
 {
     base.AddObject("tblOutletType", tblOutletType);
 }
 /// <summary>
 /// Create a new tblOutletType 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 tblOutletType CreatetblOutletType(global::System.Guid id, global::System.String name, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status)
 {
     tblOutletType tblOutletType = new tblOutletType();
     tblOutletType.id = id;
     tblOutletType.Name = name;
     tblOutletType.IM_DateCreated = iM_DateCreated;
     tblOutletType.IM_DateLastUpdated = iM_DateLastUpdated;
     tblOutletType.IM_Status = iM_Status;
     return tblOutletType;
 }
        private tblOutletType GetOutletType(string outlettypeCode)
        {
            using (var ctx = new CokeDataContext(Con))
            {
                tblOutletType outletType = null;
                if (!string.IsNullOrEmpty(outlettypeCode))
                {
                    outletType = ctx
                        .tblOutletType.FirstOrDefault(
                            p => p.Code != null &&
                                 p.Code.ToLower() == outlettypeCode.ToLower() ||
                                 p.Name != null && p.Name.ToLower() == outlettypeCode.ToLower());
                }
                if(outletType==null)
                outletType = ctx.tblOutletType.FirstOrDefault(p => p.Code == "default");

                if(outletType==null)
                {
                    var item = new tblOutletType()
                                   {
                                       Code = "default",
                                       Name = "default",
                                       id = Guid.NewGuid(),
                                       IM_DateCreated = DateTime.Now,
                                       IM_DateLastUpdated = DateTime.Now,
                                       IM_Status = (int)EntityStatus.Active
                                   };
                    ctx.tblOutletType.AddObject(item);
                    ctx.SaveChanges();
                }
                return outletType;
            }
        }