Пример #1
0
 public IntrestProfileVm(User user)
 {
     MentoringInteset = user.MentoringInteset;
     PlacementInterest = user.PlacementInterest;
     StartupInterest = user.StartupInterest;
     LectureInterest = user.LectureInterest;
 }
Пример #2
0
 public void UpdateUser(User user)
 {
     user.MentoringInteset = MentoringInteset;
     user.PlacementInterest = PlacementInterest;
     user.StartupInterest = StartupInterest;
     user.LectureInterest = LectureInterest;
 }
Пример #3
0
 public UserLog(User by, int userId)
 {
     ByUserId = by.UserId;
     ByUserName = by.FullName;
     UserId = userId;
     Init();
 }
Пример #4
0
 public ContactProfileVm(User user)
 {
     Email = user.Email;
     MobileNumber = user.MobileNumber;
     Website = user.Website;
     HomePhone = user.HomePhone;
     VisibilityOptions = Enum.GetNames(typeof(VisibilityType)).Cast<string>();
     MobileVisibility = CovertToList(user.MobileVisibility);
     EmailVisibility = CovertToList(user.EmailVisibility);
     HomePhoneVisibility = CovertToList(user.HomePhoneVisibility);
 }
Пример #5
0
 public User GetUserEntity()
 {
     var user = new User
         {
             FirstName = FirstName,
             LastName = LastName,
             Email = Email,
             UserRoles = new List<UserRole>()
         };
         return user;
 }
Пример #6
0
 public void SendEmailValidationToken(User user)
 {
     if (user.EmailConfirmedOn != null)
     {
         throw new SimpleException(string.Format("The email '{0}' is already confirmed", user.Email));
     }
     var token = _hashService.CreateTokenWithUserId(user.UserId, Constants.EmailVerificationTokenLen);
     user.EmailConfirmationToken = token;
     UpdateUser(user);
     MailSrv.SendPreDefMailAsync(user, MailType.EmailConfirmation, null);
     AddUserLog(user.UserId, "Email validation token send");
 }
Пример #7
0
 public BasicProfileVm(User user)
 {
     FirstName = user.FirstName;
     LastName = user.LastName;
     MaritialStatus = user.MaritialStatus;
     Sex = user.Sex;
     BloodGroup = user.BloodGroup;
     CanDonateBlood = user.CanDonateBlood;
     DateOfBirth = user.DateOfBirth;
     if (user.DateOfBirth != null)
     {
         var date = user.DateOfBirth.Value.Date;
         BirthDay = date.Day;
         BirthYear = date.Year;
         BirthMonth = date.Month;
     }
 }
Пример #8
0
        private User UpgradeAutoToManual(RegisterUserVm userDetails, User user)
        {
            if (userDetails.Email.ToLower() != user.Email.ToLower())
            {
                _userService.ValidateEmailUnique(userDetails.Email);
            }

            user.Email = userDetails.Email;
            user.MobileNumber = string.IsNullOrEmpty(userDetails.MobileNumber) ? user.MobileNumber : userDetails.MobileNumber;

            user.CreateType = UserCreateTypes.AutoManual;
            user.JoinedOn = DateTime.UtcNow;

            user.AccountStatus = UserRegisterStatus.Approved;
            user.EmailConfirmedOn = null;
            user.MobileNumber = userDetails.MobileNumber;
            user.HashedPassword = _hashService.CreateHash(userDetails.Password);

            _db.Entry(user).State = System.Data.EntityState.Modified;
            _db.SaveChanges();
            AddUserLog(user.UserId, "User converted from auto to manual");
            return user;
        }
Пример #9
0
 private UserCourse UpdateCourseDetails(string batch, int branchId, User user)
 {
     var course = new UserCourse
     {
         Batch = batch,
         BranchId = branchId,
     };
     course.UpdateCourseNames();
     user.UserCourses = new List<UserCourse> { course };
     return course;
 }
Пример #10
0
 static string GetCompleteMessage(MailType type, User user)
 {
     var msg = MailMap[type].Message;
     switch (type)
     {
         case MailType.RegAcknowledge:
             break;
         case MailType.RegApproved:
             break;
         case MailType.ForgotPassword:
             msg = string.Format(msg, user.PasswordResetToken);
             break;
         case MailType.Notification:
             break;
         case MailType.EmailConfirmation:
             msg = string.Format(msg, user.EmailConfirmationToken);
             break;
         default:
             break;
     }
     return msg;
 }
Пример #11
0
 public void UpdateUser(User user)
 {
     user.UpdateSkills(SeleSkills);
 }
 public JsonResult UpdateAffinity(int id, int status)
 {
     var ip = Request.UserHostAddress;
     TweetAffinity aff;
     User user;
     if (IsAuth)
     {
         user = CurrentUser;
         aff = _db.TweetAffinities.FirstOrDefault(c => c.UserId == user.UserId && c.AlumniToKnowId == id);
     }
     else
     {
         aff = _db.TweetAffinities.FirstOrDefault(c => c.IPAddress == ip && c.UserId == 0 && c.AlumniToKnowId == id);
         user = new User
         {
             UserId = 0,
             FirstName = "Uk",
             LastName = "Uk"
         };
     }
     if (aff == null)
     {
         _db.TweetAffinities.Add(new TweetAffinity
             {
                 AlumniToKnowId= id,
                 Status = status == 1 ? AffinityStatus.Agree : AffinityStatus.Disagree,
                 TimeStamp= DateTime.UtcNow,
                 UserId = user.UserId,
                 UserName = user.FullName,
                 IPAddress = Request.UserHostAddress
             });
         _db.SaveChanges();
     }
     else
     {
         aff.Status = status == 1 ? AffinityStatus.Agree : AffinityStatus.Disagree;
         aff.TimeStamp = DateTime.UtcNow;
         _db.Entry(aff).State = System.Data.EntityState.Modified;
         _db.SaveChanges();
     }
     var comment = _db.AlumnisToKnow
                     .Include(c => c.Affinities)
                     .Single(d => d.AlumniToKnowId == id);
     var json = new
     {
         l = comment.AgreeCnt,
         d = comment.DisagreeCnt,
     };
     return Json(json);
 }
Пример #13
0
 public static bool SendMail(User user, string message, string subject)
 {
     bool status = true;
     try
     {
         RestSharp.RestClient client = new RestClient();
         client.BaseUrl = "https://api.mailgun.net/v2";
         client.Authenticator =
                 new HttpBasicAuthenticator("api",
                                            "key-3eipp68fja382ul8imvyjoiao1qvggw5");
         RestRequest request = new RestRequest();
         request.AddParameter("domain",
                              "smtp.mailgun.org", ParameterType.UrlSegment);
         request.Resource = "nitcalumni.com/messages";
         request.AddParameter("from", "NITC Alumni Association<*****@*****.**>");
         request.AddParameter("to", user.Email);
         //request.AddParameter("to", "*****@*****.**");
         //request.AddParameter("to", "*****@*****.**");
         request.AddParameter("subject", subject);
         request.AddParameter("html", message);
         request.Method = Method.POST;
         client.Execute(request);
     }
     catch
     {
         status = false;
     }
     return status;
 }
Пример #14
0
 protected void UpdateEntity(User user)
 {
     _db.Entry(user).State = System.Data.EntityState.Modified;
     _db.SaveChanges();
 }
Пример #15
0
 public void UpdateUser(User user)
 {
     user.Sex = Sex;
     user.MaritialStatus = MaritialStatus;
     user.LastName = LastName;
     user.FirstName = FirstName;
     user.CanDonateBlood = CanDonateBlood;
     user.BloodGroup = BloodGroup;
     if (BirthDay == 0 && BirthMonth == 0 && BirthYear == 0)
     {
         user.DateOfBirth = null;
     }
     else
     {
         user.DateOfBirth = new DateTime(BirthYear, BirthMonth, BirthDay);
     }
 }
Пример #16
0
 public static void SendNewsletterAsync(User user, string message, string subject, Action<bool> callBack)
 {
     new Thread(new ThreadStart(() =>
     {
         bool status = true;
         try
         {
             SendMail(user, AddNewsLetterHeaderFooter(message.Replace("\n", "<br/>").Replace("\r", ""), user), subject);
         }
         catch
         {
             status = false;
         }
         if (callBack != null) callBack(status);
     }))
     .Start();
 }
Пример #17
0
 public static void SendPreDefMailAsync(User user, MailType type, Action<bool> callBack)
 {
     if (EN_MAIL_NT)
     {
         new Thread(new ThreadStart(() =>
         {
             bool status = true;
             try
             {
                 var content = MailMap[type];
                 var msg = GetCompleteMessage(type, user);
                 var fullMsg  = AddHeaderFooter(msg.Replace("\n", "<br/>").Replace("\r", ""), user);
                 SendMail(user, fullMsg, content.Subject);
             }
             catch
             {
                 status = false;
             }
             if (callBack != null) callBack(status);
         }))
         .Start();
     }
 }
        void LogSessionAsync(string browser, string ip, User user, string sessionId)
        {
            new Thread(new ThreadStart(() =>
            {
                try
                {
                    using (var db = new AlumniDbContext())
                    {
                        var session = new Session();
                        session.Browser = browser;
                        session.IPAddress = ip;
                        session.UserName = user.FullName;
                        session.Start = DateTime.UtcNow;
                        session.UserId = user.UserId;
                        session.SessionId = sessionId;

                        var pastActSession = db.UserSessions.Where(s => s.UserId == user.UserId && s.End == null && s.IPAddress ==  ip);
                        foreach (var item in pastActSession)
                        {
                            item.End = DateTime.UtcNow;
                            db.Entry(item).State = System.Data.EntityState.Modified;
                        }

                        db.UserSessions.Add(session);
                        db.SaveChanges();
                    }
                }
                catch { }
            })).Start();
        }
Пример #19
0
 static string AddHeaderFooter(string message, User user)
 {
     message = "Hi " + user.FullName + ",<br/><br/>" +  message;
     message += SIGN;
     message = HEADER + "<div style='background:#f0f2f5;font-family:Arial;padding:20px;color:#444;line-height:22px'>" + message + "</div><br/><hr/><div style='color:#777;'>Note: This is a system generated mail. Please do not reply to this mail.</div>";
     return message;
 }
Пример #20
0
 public void UpdateUser(User user)
 {
     user.Email = Email;
     user.MobileNumber = MobileNumber;
     user.Website = Website;
     user.HomePhone = HomePhone;
     user.HomePhoneVisibility = CovertToCode(HomePhoneVisibility);
     user.MobileVisibility = CovertToCode(MobileVisibility);
     user.EmailVisibility = CovertToCode(EmailVisibility);
 }
Пример #21
0
 static string AddNewsLetterHeaderFooter(string message, User user)
 {
     message += SIGN;
     message = NEWS_HEADER + "<div style='background:#fff;border:1px solid #ddd;border-top:1px solid #000;font-family:Arial;padding:20px;color:#444;line-height:22px'>" + message + "</div><br/><hr/><div style='color:#777;'>Note: This is a system generated mail. Please do not reply to this mail.</div>";
     return message;
 }
Пример #22
0
 public void SetUser(User user)
 {
     UserName = user.FullName;
     Batch = user.UserCourses[0].Batch;
     Branch = user.UserCourses[0].BranchName;
     UserId = user.UserId;
 }
Пример #23
0
 public SkillVm(User user)
 {
     SeleSkills = user.GetSkills().ToArray();
 }