private SupplierDTO Map(tblSupplier tbl)
 {
     var dto = new SupplierDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.Name,
                       Description = tbl.Description,
                       Code = tbl.Code
                   };
     return dto;
 }
Esempio n. 2
0
 /// <summary>
 /// Create a new tblSupplier 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 tblSupplier CreatetblSupplier(global::System.Guid id, global::System.String name, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status)
 {
     tblSupplier tblSupplier = new tblSupplier();
     tblSupplier.id = id;
     tblSupplier.Name = name;
     tblSupplier.IM_DateCreated = iM_DateCreated;
     tblSupplier.IM_DateLastUpdated = iM_DateLastUpdated;
     tblSupplier.IM_Status = iM_Status;
     return tblSupplier;
 }
Esempio n. 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tblSupplier EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblSupplier(tblSupplier tblSupplier)
 {
     base.AddObject("tblSupplier", tblSupplier);
 }
        private tblSupplier HandleDefaultSupplier(string code)
        {
           tblSupplier supp = null;
                if (!string.IsNullOrEmpty(code))
                {
                    supp =ObjectFactory.GetInstance<CokeDataContext>().tblSupplier.FirstOrDefault(
                        p => p.Code != null && p.Code.ToLower() == code.ToLower()||p.Name !=null && p.Name.ToLower()==code.ToLower());
                }

                if (supp == null)
                {
                    var date = DateTime.Now;
                    supp = ObjectFactory.GetInstance<CokeDataContext>().tblSupplier.FirstOrDefault(
                        p => p.Code != null && p.Code.ToLower() == "default");
                    if(supp==null)
                    {
                        supp = new tblSupplier()
                                   {
                                       id = Guid.NewGuid(),
                                       Code = string.IsNullOrEmpty(code) ? "default" : code,
                                       Name = string.IsNullOrEmpty(code) ? "default" : code,
                                       Description = string.IsNullOrEmpty(code) ? "default" : code,
                                       IM_DateCreated = date,
                                       IM_DateLastUpdated = date,
                                       IM_Status = (int) EntityStatus.Active,
                                   };
                    ObjectFactory.GetInstance<CokeDataContext>().tblSupplier.AddObject(supp);
                    ObjectFactory.GetInstance<CokeDataContext>().SaveChanges();
                    }
                }
                return supp;
            
        }
Esempio n. 5
0
        private tblProductBrand GetProductBrand(string itemName)
        {
            using (var ctx = new CokeDataContext(Con))
            {
                tblProductBrand pitem = null;
                if (!string.IsNullOrEmpty(itemName))
                    pitem = ctx
                        .tblProductBrand.FirstOrDefault(
                            p =>
                            p.name.ToLower() == itemName.ToLower() ||
                            p.code != null &&
                            p.code.ToLower() == itemName.ToLower())??ctx
                        .tblProductBrand.FirstOrDefault(
                            p =>
                            p.name.ToLower()=="default");

                if(pitem==null)
                {
                    var date = DateTime.Now;
                    var supp = ctx.tblSupplier.FirstOrDefault(p => p.Code == "default");
                    if(supp==null)
                    {
                        supp=new tblSupplier()
                                 {
                                     Name = "default",
                                     Code = "default",
                                     Description = "default",
                                     IM_Status = (int)EntityStatus.Active,
                                     id = Guid.NewGuid(),
                                     IM_DateCreated = date,
                                     IM_DateLastUpdated = date
                                 };
                        ctx.tblSupplier.AddObject(supp);
                        ctx.SaveChanges();
                    }
                    pitem = new tblProductBrand()
                                {
                                    IM_Status = (int) EntityStatus.Active,
                                    id = Guid.NewGuid(),
                                    name = string.IsNullOrEmpty(itemName) ? "default" : itemName,
                                    description = string.IsNullOrEmpty(itemName) ? "default" : itemName,
                                    code = string.IsNullOrEmpty(itemName) ? "default" : itemName,
                                    SupplierId = supp.id,
                                    IM_DateCreated = date,
                                    IM_DateLastUpdated = date

                                };
                    ctx.tblProductBrand.AddObject(pitem);
                    ctx.SaveChanges();
                }

                
                return pitem;
            }
        }