コード例 #1
0
ファイル: MyProfileService.cs プロジェクト: e4softwares/SME
 public bool SaveUserDetail(UserCompanyDetail userCompanyDetail)
 {
     bool blnValue = true;
     using (var dbContextTransaction = _dbContext.Database.BeginTransaction())
     {
         try
         {
             _UserCompanyDetail.Add(userCompanyDetail);
             _dbContext.SaveChanges();
             dbContextTransaction.Commit();
         }
         catch (Exception)
         {
             blnValue = false;
             dbContextTransaction.Rollback();
         }
     }
     return blnValue;
 }
コード例 #2
0
ファイル: MyProfileService.cs プロジェクト: e4softwares/SME
        public bool UpdateUserDetail(UserCompanyDetail userCompanyDetail)
        {
            bool blnValue = true;
            using (var dbContextTransaction = _dbContext.Database.BeginTransaction())
            {
                try
                {
                    _UserCompanyDetail.Attach(userCompanyDetail);
                    var entry = _dbContext.Entry(userCompanyDetail);
                    entry.Property(e => e.BussinessNature).IsModified = true;
                    entry.Property(e => e.CompanyName).IsModified = true;
                    entry.Property(e => e.CompanyType).IsModified = true;
                    entry.Property(e => e.IndustryType).IsModified = true;
                    entry.Property(e => e.OperationYear).IsModified = true;
                    entry.Property(e => e.PancardNo).IsModified = true;
                   // entry.Property(e => e.).IsModified = true;
                    _dbContext.SaveChanges();
                    dbContextTransaction.Commit();

                }
                catch (Exception)
                {
                    blnValue = false;
                    dbContextTransaction.Rollback();
                }
            }
            return blnValue;
        }
コード例 #3
0
        public string SaveUserRegistration(UserDetail userDetail)
        {
            using (var dbContextTransaction = _dbContext.Database.BeginTransaction())
            {
                try
                {
                    _UserDetail.Add(userDetail);
                    _dbContext.SaveChanges();

                    UserCompanyDetail objUserCompanyDetail = new UserCompanyDetail();
                    objUserCompanyDetail.UserId = userDetail.Id;
                    objUserCompanyDetail.CompanyName = userDetail.CompanyName;
                    objUserCompanyDetail.CreatedBy = userDetail.CreatedBy;
                    objUserCompanyDetail.CreatedDate = userDetail.CreatedDate;
                    _UserCompanyDetail.Add(objUserCompanyDetail);
                    _dbContext.SaveChanges();

                    dbContextTransaction.Commit();
                }
                catch (Exception)
                {
                    dbContextTransaction.Rollback();
                }
            }
            return "";
        }