예제 #1
0
 public string Add(Member member)
 {
     try
     {
         if (member != null)
         {
             if (!IsDuplicate(string.Empty, member.UserName))
             {
                 string UserID = CommonConstant.GetFieldValueString(Session[CommonConstant.SessionUserID]);
                 RSACrypto crypto = new RSACrypto();
                 member.MemberID = Guid.NewGuid().ToString();
                 member.Password = crypto.Encrypt(CommonConstant.DefaultPassword);
                 member.DealerID = UserID;
                 member.UpdateBy = UserID;
                 member.UpdateDate = DateTime.Now;
                 member.CreateBy = UserID;
                 member.CreateDate = DateTime.Now;
                 db.Members.Add(member);
                 db.SaveChanges();
                 return "Success";
             }
             else
             {
                 return "This username is already in used.";
             }
         }
     }
     catch (Exception ex)
     {
         LogFile.writeLogFile(DateTime.Now, "MemberController", ex.ToString());
     }
     return "Add new member failed";
 }
예제 #2
0
 public string ResetPassword(string id)
 {
     try
     {
         if (id != string.Empty)
         {
             RSACrypto crypto = new RSACrypto();
             Member mem = db.Members.Find(id);
             mem.Password = crypto.Encrypt(CommonConstant.DefaultPassword);
             mem.UpdateBy = CommonConstant.GetFieldValueString(Session[CommonConstant.SessionUserID]);
             mem.UpdateDate = DateTime.Now;
             db.Entry(mem).State = EntityState.Modified;
             db.SaveChanges();
             return "Success";
         }
     }
     catch (Exception ex)
     {
         LogFile.writeLogFile(DateTime.Now, "MemberController", ex.ToString());
     }
     return "Update failed";
 }