public override ResponseViewModelBase Validate()
        {
            var response = new ResponseMessageViewModel();

            if (_fileService.GetFileById(FileId) == null)
            {
                response.AddError(ResourceKeyResolver.ErrorFileNotChoosen);
                return response;
            }
            if (FileId == 0 || (UserId == 0 && UserName.IsEmpty()))
            {
                response.AddError(ResourceKeyResolver.ErrorWrongDataPassed);
                return response;
            }

            var userId = UserId == 0 ? _userService.GetServiceUserId(UserName) : UserId;

            if (_fileService.UserHasAccess(FileId, userId))
            {
                response.AddError(ResourceKeyResolver.ErrorUserHasAccessToFile);
                return response;
            }

            IsValid = true;
            return response;
        }
        public override ResponseViewModelBase Validate()
        {
            var response = new ResponseMessageViewModel();

            IsValid = true;
            return response;
        }
 public AllNotesDetailsViewModel()
 {
     Response = new ResponseMessageViewModel();
     NoteOwner = new SimpleUserModel();
     NoteGroup = new List<SimpleGroupModel>();
     Note = new Note();
     NoteTags = new NoteTagsViewModel();
 }
        public override ResponseViewModelBase Validate()
        {
            var response = new ResponseMessageViewModel();

            if (NinjectResolver.GetInstance<ISchoolService>().SchoolContainsGrade(UniversityId, SchoolGrade))
            {
                response.ErrorList.Add(ResourceKeyResolver.ErrorUniversityContainsGrade);
                return response;
            }

            IsValid = true;
            return response;
        }
Example #5
0
        public async Task <ResponseMessageViewModel> ForgotUserName(string email)
        {
            var response = new ResponseMessageViewModel();

            if (!string.IsNullOrEmpty(email))
            {
                var externalUser = await _context.Users
                                   .Where(a => a.EmailAddress == email)
                                   .Select(a => new { a.UserName, a.Id, a.EmailAddress }).FirstOrDefaultAsync();

                if (externalUser != null)
                {
                    var profile = await _context.Profiles
                                  .Where(a => a.UserId == externalUser.Id)
                                  .Select(a => new
                    {
                        FullName = string.Format("{0}, {1} {2}", a.LastName, a.FirstName, a.MiddleName)
                    }).FirstOrDefaultAsync();

                    string        subject = "FAA DMS Log in Username";
                    StringBuilder sbrbody = new StringBuilder();
                    sbrbody.Append(string.Format("Dear {0}", profile.FullName));
                    sbrbody.AppendLine().AppendLine().Append("Please find your username for log in as following");
                    sbrbody.AppendLine().Append(string.Format("User name : {0}", externalUser.UserName));
                    sbrbody.AppendLine().AppendLine().Append("Designee Management System (DMS),").AppendLine().Append("Administration.");
                    string body = sbrbody.ToString();

                    // try
                    // {
                    _emailDomainService.SendEmail(new List <string>()
                    {
                        externalUser.EmailAddress
                    }, new List <string>(), subject, body, null);
                    // }
                    // catch (Exception)
                    // {

                    // }

                    response.success = true;
                    response.Message = string.Format("An email has been sent to {0} with the User Name. Please click ok to return to the home page.", externalUser.EmailAddress);
                }
                else
                {
                    response.success = false;
                    response.Message = "The email address is either invalid or cannot be found.";
                }
            }

            return(response);
        }
        public override ResponseViewModelBase Validate()
        {
            var response = new ResponseMessageViewModel();

            if (UniversityName.IsEmpty())
            {
                response.ErrorList.Add(ResourceKeyResolver.ErrorUniversityNameNotDefined);
                return response;
            }

            IsValid = true;

            return response;
        }
        public SecureUserModel(User user)
        {
            Response = new ResponseMessageViewModel();

            UserId = user.UserId;
            Email = user.Email;
            Name = user.UserInfo.Name;
            LastName = user.UserInfo.LastName;
            Profession = user.UserInfo.Profession;
            PhoneNumber = user.UserInfo.PhoneNumber;
            Country = user.UserInfo.Country;
            City = user.UserInfo.City;
            PostalCode = user.UserInfo.PostalCode;
            Street = user.UserInfo.Street;
            PicturePath = user.UserInfo.PicturePath;
            CreatedOn = user.UserInfo.CreatedOn;
            Gender = user.UserInfo.Gender;
        }
        public override ResponseViewModelBase Validate()
        {
            var response = new ResponseMessageViewModel();

            if (_fileService.GetFileById(FileId) == null || !_groupService.GroupExists(GroupId) || !_groupService.SemesterSubjectExists(SemesterSubjectId))
            {
                response.ErrorList.Add(ResourceKeyResolver.ErrorWrongDataPassed);
                return response;
            }
            if (_groupService.FileSharedToGroup(FileId, GroupId, SemesterSubjectId))
            {
                response.ErrorList.Add(ResourceKeyResolver.ErrorGroupHasAccessToFile);
                return response;
            }

            IsValid = true;
            return response;
        }
Example #9
0
        public async Task <ResponseMessageViewModel> ChangePassword(ForgotUserNameChangePasswordViewModel model)
        {
            var respone = new ResponseMessageViewModel();
            var user    = await _context.Users
                          .Where(a => a.UserName == model.UserName)
                          .Select(a => a).FirstOrDefaultAsync();

            if (user != null)
            {
                user.Password = _saltPasswordService.SaltPassword(model.Password);
                _context.SaveChanges();
                respone.success = true;
                respone.Message = "The password has been changed successfully.";
            }
            else
            {
                respone.success = false;
                respone.Message = "Failed to update password.";
            }
            return(respone);
        }
 public RecentlyAddedNotesViewModel()
 {
     Response = new ResponseMessageViewModel();
     Notes = new List<Note>();
 }
 public SearchedNotesViewModel()
 {
     Response = new ResponseMessageViewModel();
     Notes = new List<Note>();
 }
 public AllNotesViewModel()
 {
     Response = new ResponseMessageViewModel();
     Notes = new List<Note>();
 }
 public UniversityViewModel()
 {
     Universities = new List<School>();
     Response = new ResponseMessageViewModel();
 }
 public UniversitySemesterSubjectNotesViewModel()
 {
     Notes = new List<Note>();
     Response = new ResponseMessageViewModel();
 }
 public NoteTagsViewModel()
 {
     Response = new ResponseMessageViewModel();
 }
 public SharedNotesViewModel()
 {
     Response = new ResponseMessageViewModel();
     Notes = new List<SimpleNoteModel>();
 }
 public UserNotesViewModel()
 {
     Response = new ResponseMessageViewModel();
     UserNotesList = new List<Note>();
 }
 public SecureUserModel()
 {
     Response = new ResponseMessageViewModel();
 }
 public UniversityGradeStudySubjectViewModel()
 {
     Response = new ResponseMessageViewModel();
     StudyGrades = new List<Grade>();
 }
        public ActionResult SaveUserPreferences(UserPreferencesViewModel model)
        {
            var serverResponse = new ResponseMessageViewModel();
            model.UserId = (int)Session["CurrentUserId"];

            if (_userService.UpdateUserPreferences(model))
            {
                serverResponse.AddSuccess(ResourceKeyResolver.SuccessUserPreferencesUpdated);
                }
            else
            {
                serverResponse.AddError(ResourceKeyResolver.ErrorUserPreferencesUpdated);
            }

            TempData["ServerResponse"] = serverResponse;

            return RedirectToAction("ChangedPreferencesRedirect");
        }
        public ActionResult ChangeAvatar(HttpPostedFileBase file)
        {
            var serverResponse = new ResponseMessageViewModel();

            if (file == null || file.ContentLength == 0)
            {
                serverResponse.AddError(ResourceKeyResolver.ErrorWrongAvatar);
            }
            else
            {
                var fileExtension = file.FileName.Split('.').Last(e => !e.IsEmpty());
                var fileName = $"{(int)Session["CurrentUserId"]}_avatar.{fileExtension}";
                var path = Path.Combine(Server.MapPath("~/Resources/Avatars"), fileName);

                file.SaveAs(path);
                _userService.AddAvatar((int)Session["CurrentUserId"], $"/Resources/Avatars/{fileName}");
                serverResponse.AddSuccess(ResourceKeyResolver.SuccessAvatarChanged);
            }

            TempData["ServerResponse"] = serverResponse;

            return RedirectToAction("ChangedPreferencesRedirect");
        }
 public UniversityNotesViewModel()
 {
     Response = new ResponseMessageViewModel();
     Notes = new List<Note>();
 }
 public NewUniversityViewModel()
 {
     Response = new ResponseMessageViewModel();
     GradeList = new List<Grade>();
 }
 public AccessedNotesViewModel()
 {
     Response = new ResponseMessageViewModel();
     Notes = new List<Note>();
     Owners = new List<SimpleUserModel>();
 }