public static DTO_PRO_HoiNghiHoiThao_DangKy post_PRO_HoiNghiHoiThao_DangKyCustom(AppEntities db, DTO_PRO_HoiNghiHoiThao_DangKy item, string Username)
        {
            tbl_PRO_HoiNghiHoiThao_DangKy dbitem = new tbl_PRO_HoiNghiHoiThao_DangKy();

            if (item != null)
            {
                dbitem.IDNhanVien       = item.IDNhanVien;
                dbitem.IDHoiNghiHoiThao = item.IDHoiNghiHoiThao;

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

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

                var hoinghi = db.tbl_PRO_HoiNghiHoiThao.FirstOrDefault(c => c.ID == item.IDHoiNghiHoiThao);
                if (hoinghi != null)
                {
                    if (hoinghi.ThoiGianHetHan < DateTime.Now)
                    {
                        item.Error = "Hội nghị đã hết hạn đăng ký!";
                        return(item);
                    }
                }

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

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_HoiNghiHoiThao_DangKy", DateTime.Now, Username);


                    item.ID = dbitem.ID;

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

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_PRO_HoiNghiHoiThao_DangKy", e);
                    item = null;
                }
            }
            return(item);
        }
Exemplo n.º 2
0
 public static DTO_PRO_HoiNghiHoiThao_DangKy toDTO(tbl_PRO_HoiNghiHoiThao_DangKy dbResult)
 {
     if (dbResult != null)
     {
         return(new DTO_PRO_HoiNghiHoiThao_DangKy()
         {
             ID = dbResult.ID,
             IDNhanVien = dbResult.IDNhanVien,
             IDHoiNghiHoiThao = dbResult.IDHoiNghiHoiThao,
             CreatedDate = dbResult.CreatedDate,
             CreatedBy = dbResult.CreatedBy,
             ModifiedDate = dbResult.ModifiedDate,
             ModifiedBy = dbResult.ModifiedBy,
         });
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 3
0
        public static DTO_PRO_HoiNghiHoiThao_DangKy post_PRO_HoiNghiHoiThao_DangKy(AppEntities db, DTO_PRO_HoiNghiHoiThao_DangKy item, string Username)
        {
            tbl_PRO_HoiNghiHoiThao_DangKy dbitem = new tbl_PRO_HoiNghiHoiThao_DangKy();

            if (item != null)
            {
                dbitem.IDNhanVien       = item.IDNhanVien;
                dbitem.IDHoiNghiHoiThao = item.IDHoiNghiHoiThao;

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

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


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

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_PRO_HoiNghiHoiThao_DangKy", DateTime.Now, Username);


                    item.ID = dbitem.ID;

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

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_PRO_HoiNghiHoiThao_DangKy", e);
                    item = null;
                }
            }
            return(item);
        }