Beispiel #1
0
 public DAL.DBContext.IssuedCard DoneEnrolSupervisee(string UserId)
 {
     new DAL_UserProfile().CreateUserProfileIfNotExit(UserId);
     _localUnitOfWork.DataContext.Database.BeginTransaction();
     DAL.DBContext.IssuedCard IssueCard = null;
     try
     {
         IssueCard        = _localUnitOfWork.DataContext.IssuedCards.Where(d => d.UserId.Equals(UserId)).OrderByDescending(d => d.CreatedDate).FirstOrDefault();
         IssueCard.Status = EnumIssuedCards.Active;
         DAL.DBContext.Membership_Users member_user = _localUnitOfWork.DataContext.Membership_Users.FirstOrDefault(d => d.UserId.Equals(UserId));
         member_user.SmartCardId = IssueCard.SmartCardId;
         member_user.Status      = EnumUserStatuses.Enrolled;
         DBContext.User_Profiles user = _localUnitOfWork.DataContext.User_Profiles.FirstOrDefault(d => d.UserId == UserId);
         user.Serial_Number = IssueCard.Serial_Number;
         user.Date_of_Issue = IssueCard.Date_Of_Issue;
         user.Expired_Date  = IssueCard.Expired_Date;
         _localUnitOfWork.GetRepository <DBContext.User_Profiles>().Update(user);
         _localUnitOfWork.GetRepository <DBContext.Membership_Users>().Update(member_user);
         _localUnitOfWork.GetRepository <DAL.DBContext.IssuedCard>().Update(IssueCard);
         _localUnitOfWork.DataContext.SaveChanges();
         _localUnitOfWork.DataContext.Database.CurrentTransaction.Commit();
     }
     catch (Exception ex)
     {
         _localUnitOfWork.DataContext.Database.CurrentTransaction.Rollback();
         throw ex;
     }
     return(IssueCard);
 }
Beispiel #2
0
 public void UpdateCardInfo(string UserId, string CardNumber, DateTime Date_of_Issue, DateTime Expired_Date)
 {
     if (EnumAppConfig.IsLocal)
     {
         bool statusCentralized;
         CallCentralized.Post("User_Profiles", "UpdateCardInfo", out statusCentralized, "UserId=" + UserId, "CardNumber=" + CardNumber, "Date_of_Issue=" + Date_of_Issue.ToString(), "Expired_Date=" + Expired_Date.ToString());
         if (!statusCentralized)
         {
             throw new Trinity.Common.ExceptionArgs(EnumMessage.NotConnectCentralized);
         }
         else
         {
             DBContext.User_Profiles user = _localUnitOfWork.DataContext.User_Profiles.FirstOrDefault(d => d.UserId == UserId);
             user.Serial_Number = CardNumber;
             user.Date_of_Issue = Date_of_Issue;
             user.Expired_Date  = Expired_Date;
             _localUnitOfWork.GetRepository <DBContext.User_Profiles>().Update(user);
             _localUnitOfWork.Save();
         }
     }
     else
     {
         DBContext.User_Profiles user = _centralizedUnitOfWork.DataContext.User_Profiles.FirstOrDefault(d => d.UserId == UserId);
         user.Serial_Number = CardNumber;
         user.Date_of_Issue = Date_of_Issue;
         user.Expired_Date  = Expired_Date;
         _centralizedUnitOfWork.GetRepository <DBContext.User_Profiles>().Update(user);
         _centralizedUnitOfWork.Save();
     }
 }