public IActionResult Register(RegisterForm registerForm) { bool screenName = _userRepository.GetAll().Where(u => u.ScreenName == registerForm.ScreenName).FirstOrDefault() is null; bool email = _userRepository.GetAll().Where(u => u.Email == registerForm.Email).FirstOrDefault() is null; if (!(registerForm is null) && ModelState.IsValid) { registerForm.Passwd = Convert.ToBase64String(_cryptoService.Crypter(registerForm.Passwd)); try { if (screenName && email) { _authRepository.Register(registerForm); return(RedirectToAction("Login")); } else if (!screenName) { ViewBag.Message = "Screen Name already exists"; } else { ViewBag.Message = "Email already used"; } } catch (Exception ex) { return(View("Error")); } } return(View(registerForm.ToWeb())); }
public ActionResult Edit(int id, EditUser form) { User u = _userRequester.Get(SessionManager.User.Id); bool canUpdate = form.LastName != u.LastName || form.FirstName != u.FirstName || form.ScreenName != u.ScreenName || form.Email != u.Email || form.Address != u.Address; bool screenName = _userRequester.GetAll().Where(u => u.Id != SessionManager.User.Id && u.ScreenName == form.ScreenName).FirstOrDefault() is null; bool email = _userRequester.GetAll().Where(u => u.Id != SessionManager.User.Id && u.Email == form.Email).FirstOrDefault() is null; try { if (ModelState.IsValid && (SessionManager.User.Id == id) && !(SessionManager.User.Token is null)) { if (canUpdate) { if (screenName && email) { _apiTokenRequester.UpdateWithToken(new User(id, form.LastName, form.FirstName, form.ScreenName, form.Email, form.Address) , "user/" + id, SessionManager.User.Token); ViewBag.Message = "Profile successfully updated"; return(RedirectToAction(nameof(Index))); } else if (!screenName) { ViewBag.Message = "Screen Name already used"; } else { ViewBag.Message = "Email address not avilable"; } return(View(form)); } ViewBag.Message = "You changed nothing, nice try"; return(View(form)); } ViewBag.Message = "Session has expired"; return(RedirectToAction("Index", "Auth")); } catch { return(View("Error")); } }
public IEnumerable <User> GetAll() { return(_userRepository.GetAll()); }
//private void OnDeleteUser(UserViewModel instance) // * //{ // Items.Remove(instance); //} protected override ObservableCollection <UserViewModel> LoadItems() { return(new ObservableCollection <UserViewModel>(_userRequester.GetAll().Select(u => new UserViewModel(u)))); }
public IEnumerable <Event> GetAll() { return(_eventRepository.GetAll()); }
// GET: Event public ActionResult Index() { return(View(_eventRequester.GetAll() .Where(e => e.Date >= DateTime.Now || e.Date is null) .OrderBy(e => e.Date))); }
//private void OnDeleteEvent(EventViewModel instance) // * //{ // Items.Remove(instance); //} protected override ObservableCollection <EventViewModel> LoadItems() { return(new ObservableCollection <EventViewModel>(_eventRequester.GetAll().Select(e => new EventViewModel(e)))); }