private ProductBrandDTO Map(tblProductBrand tbl)
 {
     var dto = new ProductBrandDTO
                   {
                       MasterId = tbl.id,
                       DateCreated = tbl.IM_DateCreated,
                       DateLastUpdated = tbl.IM_DateLastUpdated,
                       StatusId = tbl.IM_Status,
                       Name = tbl.name,
                       Code = tbl.code,
                       Description = tbl.description,
                       SupplierMasterId = tbl.SupplierId ?? Guid.Empty
                   };
     return dto;
 }
Example #2
0
 /// <summary>
 /// Create a new tblProductBrand 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 tblProductBrand CreatetblProductBrand(global::System.Guid id, global::System.String name, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status)
 {
     tblProductBrand tblProductBrand = new tblProductBrand();
     tblProductBrand.id = id;
     tblProductBrand.name = name;
     tblProductBrand.IM_DateCreated = iM_DateCreated;
     tblProductBrand.IM_DateLastUpdated = iM_DateLastUpdated;
     tblProductBrand.IM_Status = iM_Status;
     return tblProductBrand;
 }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tblProductBrand EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblProductBrand(tblProductBrand tblProductBrand)
 {
     base.AddObject("tblProductBrand", tblProductBrand);
 }
        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;
            }
        }
 private tblProductFlavour GetProductFlavour(string itemName,tblProductBrand brand)
 {
     using (var ctx = new CokeDataContext(Con))
     {
         tblProductFlavour pitem = null;
         if (!string.IsNullOrEmpty(itemName))
         {
             pitem = ctx
                         .tblProductFlavour.FirstOrDefault(
                             p =>
                             p.name.ToLower() == itemName.ToLower() ||
                             p.code != null &&
                             p.code.ToLower() == itemName.ToLower()) ?? ctx.tblProductFlavour.FirstOrDefault(
                                 p => p.name.ToLower() == "default");
         }
         if(pitem==null)
         {
             var date = DateTime.Now;
                 pitem = new tblProductFlavour()
                 {
                     BrandId = brand.id,
                     id = Guid.NewGuid(),
                     code = string.IsNullOrEmpty(itemName) ? "default" : itemName,
                     description = string.IsNullOrEmpty(itemName) ? "default" : itemName,
                     IM_DateCreated = date,
                     IM_DateLastUpdated = date,
                     name = string.IsNullOrEmpty(itemName) ? "default" : itemName,
                 };
                 ctx.tblProductFlavour.AddObject(pitem);
                 ctx.SaveChanges();
         }
         return pitem;
     }
 }