Example #1
0
 public static DTO_PAR_ThongTinSanPham toDTO(tbl_PAR_ThongTinSanPham dbResult)
 {
     if (dbResult != null)
     {
         return(new DTO_PAR_ThongTinSanPham()
         {
             IDPartner = dbResult.IDPartner,
             IDSanPham = dbResult.IDSanPham,
             ID = dbResult.ID,
             Code = dbResult.Code,
             Name = dbResult.Name,
             Remark = dbResult.Remark,
             Sort = dbResult.Sort,
             IsDisabled = dbResult.IsDisabled,
             IsDeleted = dbResult.IsDeleted,
             CreatedBy = dbResult.CreatedBy,
             ModifiedBy = dbResult.ModifiedBy,
             CreatedDate = dbResult.CreatedDate,
             ModifiedDate = dbResult.ModifiedDate,
             NgayDangKy = dbResult.NgayDangKy,
             NgayHetHan = dbResult.NgayHetHan,
             NgayGiaHan = dbResult.NgayGiaHan,
         });
     }
     else
     {
         return(null);
     }
 }
Example #2
0
        public static DTO_PAR_ThongTinSanPham post_PAR_ThongTinSanPham(AppEntities db, int PartnerID, DTO_PAR_ThongTinSanPham item, string Username)
        {
            tbl_PAR_ThongTinSanPham dbitem = new tbl_PAR_ThongTinSanPham();

            if (item != null)
            {
                dbitem.IDSanPham  = item.IDSanPham;
                dbitem.Code       = item.Code;
                dbitem.Name       = item.Name;
                dbitem.Remark     = item.Remark;
                dbitem.Sort       = item.Sort;
                dbitem.IsDisabled = item.IsDisabled;
                dbitem.IsDeleted  = item.IsDeleted;
                dbitem.NgayDangKy = item.NgayDangKy;
                dbitem.NgayHetHan = item.NgayHetHan;
                dbitem.NgayGiaHan = item.NgayGiaHan;

                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;

                dbitem.IDPartner = PartnerID;


                try
                {
                    db.tbl_PAR_ThongTinSanPham.Add(dbitem);
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_PAR_ThongTinSanPham", dbitem.ModifiedDate, Username);



                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;

                    item.IDPartner = dbitem.IDPartner;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_PAR_ThongTinSanPham", e);
                    item = null;
                }
            }
            return(item);
        }