public List <UsersVM> GetUsersDetails() { try { var userList = new List <UsersVM>(); using (TrainingAppEntities1 dc = new TrainingAppEntities1()) { //var data = dc1.Schedules.ToList(); var data = dc.Users.ToList(); foreach (var item in data) { UsersVM user = new UsersVM(); if (item.DeletedAt == null) { var name = string.Concat(item.FirstName + " " + item.LastName); user.UserName = name; user.UserId = item.UserId; userList.Add(user); } } } return(userList); } catch (Exception ex) { throw ex; } }
public ActionResult Create(Users user) { try { if (!ModelState.IsValid) { var userTypesList = _userTypesService.GetAll(); var model = new UsersVM { User = new Users(), UserTypes = userTypesList }; } user.CreationDate = DateTime.Now; _usersService.Add(user); TempData.Add("message", "Kullanıcı başarıyla eklendi."); return(RedirectToAction("index")); } catch (Exception ex) { TempData.Add("message", "Kullanıcı oluştururken hata ile karşılaştı. Hata: " + ex.Message); return(View()); } }
public bool AddUser(UsersVM userVM) { if (isValidUser(userVM.email, userVM.user_name)) { user_data userToAdd = new user_data(); userToAdd.user_name = userVM.user_name; userToAdd.address = userVM.address; userToAdd.age = userVM.age; userToAdd.email = userVM.email; userToAdd.national_id = userVM.national_id; userToAdd.phone = userVM.phone; userToAdd.role = userVM.role; userToAdd.qualification_id = userVM.qualification_id; userToAdd.loginUserName = userVM.loginUserName; userToAdd.password = userVM.password; userToAdd.qualification_id = userVM.qualification_id; MCDB.user_data.Add(userToAdd); MCDB.SaveChanges(); return(true); } else { return(false); } }
public ActionResult Edit(int uId, Users user) { try { if (!ModelState.IsValid) { var userTypesList = _userTypesService.GetAll(); var model = new UsersVM { User = new Users(), UserTypes = userTypesList }; } _usersService.Update(user); TempData.Add("message", "Kullanıcı bilgileri başarıyla güncellendi."); return(RedirectToAction("index")); } catch (Exception ex) { TempData.Add("message", "Kullanıcı bilgileri güncelleme işleminde hata ile karşılaştı. Hata: " + ex.Message); return(View()); } }
public TableVM() { carriagesVM = new CarriagesVM(); citiesVM = new CitiesVM(); locomotivesVM = new LocomotivesVM(); routesVM = new RoutesVM(); schedulesVM = new SchedulesVM(); ticketsVM = new TicketsVM(); trainsVM = new TrainsVM(); usersVM = new UsersVM(); CurrentModel = schedulesVM; RequestCommand = new RelayCommand(o => { CurrentModel.Request(); }); AddCommand = new RelayCommand(o => { CurrentModel.AddEdit(true); }); EditCommand = new RelayCommand(o => { CurrentModel.AddEdit(false); }); DeleteCommand = new RelayCommand(o => { CurrentModel.Delete(); }); }
public async Task <IActionResult> EditUsersGridPartial(UsersVM item) { var identity = await userManager.FindByIdAsync(item.Id); identity.Email = item.Email; identity.UserName = item.UserName; var res = await this.userManager.UpdateAsync(identity); if (item.Password != null) { var token = await userManager.GeneratePasswordResetTokenAsync(identity); res = await this.userManager.ResetPasswordAsync(identity, token, item.Password); } var model = db.AspNetUsers.Select(x => new UsersVM { Password = "", Email = x.Email, UserName = x.UserName }).ToList(); return(PartialView("UsersGridPartial", model)); }
public async Task <IActionResult> Edit(UsersVM model) { var user = await userManager.FindByIdAsync(model.Id); if (user == null) { ViewBag.ErrorMessage = $"User with id = {model.Id} cannot be found"; return(View("Error")); } else { user.FirstName = model.FirstName; user.LastName = model.LastName; user.UserName = model.UserName; user.Email = model.Email; user.NationalId = model.NationalId; user.PhoneNumber = model.PhoneNumber; user.StreetAddress = model.StreetAddress; var result = await userManager.UpdateAsync(user); if (result.Succeeded) { return(RedirectToAction("Index", "Users")); } foreach (IdentityError error in result.Errors) { ModelState.AddModelError("", error.Description); } return(View(model)); } }
public ActionResult EditPassWord(UsersVM obj) { Users users = db.Users1.AsNoTracking().Where(u => u.UserId == obj.UserId).FirstOrDefault(); if (users != null) { ModelState.Clear(); users.PassWord = mhmkobj.Encrypt(obj.UserName, obj.PassWord); // var errors = ModelState.Values.SelectMany(v => v.Errors); if (ModelState.IsValid) { try { db.Entry(users).State = EntityState.Modified; db.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(RedirectToAction("Index")); } } return(View(users)); }
public async Task <IActionResult> Create(UsersVM model) { if (ModelState.IsValid) { ApplicationUser applicationUser = new ApplicationUser { Id = model.Id, FirstName = model.FirstName, LastName = model.LastName, UserName = model.UserName, Email = model.Email, NationalId = model.NationalId, PhoneNumber = model.PhoneNumber, StreetAddress = model.StreetAddress, PasswordHash = model.Password }; IdentityResult result = await userManager.CreateAsync(applicationUser); if (result.Succeeded) { return(RedirectToAction("Index", "Users")); } foreach (IdentityError error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View(model)); }
public async Task <ReturnResult> DeleteUser([FromBody] UsersVM usersVM) { if (usersVM != null) { var existingUser = await _userService.GetAsync(x => x.Id == usersVM.UserId); if (existingUser != null) { if (_genericService.ShitfAssignment.SearchFor(x => x.UserId == usersVM.UserId && x.IsActive == true).Any()) { return(new ReturnResult { Message = "Please first delete all the shift assigment under this user", Success = false }); } //existingUser.IsActive = false; await _userService.DeleteAsync(existingUser); _genericService.Commit(); return(new ReturnResult { Message = "User is deleted successfully!", Success = true }); } } return(new ReturnResult { Message = "User is not deleted, please try again!", Success = false }); }
public async Task <IActionResult> Details(string id) { IdentityUser user = await _userManager.FindByIdAsync(id); bool admin; bool locked; if (await _userManager.IsInRoleAsync(user, "ADMIN")) { admin = true; } else { admin = false; } if (await _userManager.IsLockedOutAsync(user)) { locked = true; } else { locked = false; } usersVM = new UsersVM { User = _iUsers.GetFirstOrDefault(id), Admin = admin, IsLocked = locked }; return(View(usersVM)); }
public ActionResult Login(UsersVM model) { if (!ModelState.IsValid) { return(View(model)); } var user = _userProcess.GetUserByLoginName(model.Email); if (user != null && model.Password == user.Password) { var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Name, user.Name), new Claim(ClaimTypes.Email, user.Email) }, "ApplicationCookie" ); var ctx = Request.GetOwinContext(); var authManager = ctx.Authentication; authManager.SignIn(identity); return(RedirectToAction("index", "comment")); } ModelState.AddModelError("", "Email or password is incorrect"); return(View(model)); }
public ActionResult SubmitSignup()//action result for submiiting signup form { Users userobj = new Users(); UsersDal dal = new UsersDal(); userobj.FirstName = Request.Form["User.FirstName"]; userobj.LastName = Request.Form["User.LastName"]; userobj.UserPN = Request.Form["User.UserPN"]; userobj.UserName = Request.Form["User.UserName"]; userobj.UserEmail = Request.Form["User.UserEmail"]; userobj.UserPassword = Request.Form["User.UserPassword"]; if (ModelState.IsValid) { dal.users.Add(userobj); try { dal.SaveChanges(); } catch (DbUpdateException) { UsersVM passthis = new UsersVM(); //expecting for key violation exception coused by trying to signup with username which alrady exists passthis.user = userobj; dal.users.Remove(userobj); ViewBag.username = "******"; return(View("Signup", passthis));//recalling signup view and passing the information user submitted to the form } } return(View("../Home/ShowHomePage", (new ProductsVM() { products_list = (new ProductsDal().products.ToList()) }))); //returns to home page and loading products if sign up succeded }
public static GroupingsDataVM SetSubDataMessagingRoom(GroupingsData model, Guid aid) { var data = SetSubData(model, aid); data.User = UsersVM.MToVM(UsersService.GetByID(model.OwnerID)); data.MessagingRoom = MessagingRoomVM.MToVM(MessagingRoomService.GetByID(model.SourceID, aid)); return(data); }
public ActionResult Registration(UsersVM model) { if (ModelState.IsValid) { _userProcess.Add(model.ToDTO()); } return(View()); }
public static List <QuizTakersVM> SetUser(List <QuizTakersVM> list) { foreach (var model in list) { model.User = UsersVM.MToVM(UsersService.GetByID(Guid.Parse(model.UserID))); } return(list); }
public static UsersVM SetSubDataAdmin(Users item) { var model = UsersVM.MToVM(item); model.DateTimeData = DateTimeStorageVM.MToVM(DateTimeStorageService.GetByID(item.DateTimeStorageID)); model.ProfileImage = ImageLinkStorageVM.MToVM(ImageLinkStorageService.GetByIDAdmin(item.ProfileImageID)); return(model); }
//setting sub data sub classes of this class properties are set here public static UsersVM SetSubData(Users item, Guid aid) { var model = UsersVM.MToVM(item); model.DateTimeData = DateTimeStorageVM.MToVM(DateTimeStorageService.GetByOID(item.DateTimeStorageID, aid).FirstOrDefault()); model.ProfileImage = ImageLinkStorageVM.MToVM(ImageLinkStorageService.GetByIDAdmin(item.ProfileImageID)); return(model); }
public static UsersDTO ToDTO(this UsersVM vm) { UsersDTO dto = new UsersDTO(); dto.Email = vm.Email; dto.Name = vm.Name; dto.Password = CustomEncrypt.Encrypt(vm.Password); return(dto); }
public JsonResult registrate(UsersVM model) { if (_authHandler.CreateUser(model) != 0) { return(Json(Url.Action("login", "authentication"), JsonRequestBehavior.AllowGet)); } return(Json(string.Empty, JsonRequestBehavior.AllowGet)); }
public ActionResult Users() { var userManager = new UserManager <AppUser>(new UserStore <AppUser>(new EntityRepo())); var roleManager = new RoleManager <AppRole>(new RoleStore <AppRole>(new EntityRepo())); var vm = new UsersVM(); vm.SetUsers(userManager, roleManager); return(View(vm)); }
public IActionResult Index() { usersVM = new UsersVM { Users = _iUsers.GetAll() }; return(View(usersVM)); }
public ActionResult Users() { var users = _repository.FindAll(); var usersVM = new UsersVM { Users = users }; return(View(usersVM)); }
public IActionResult Index() { var userid = _userManager.GetUserId(this.User); usersVM = new UsersVM { User = _iUser.GetFirstOrDefault(userid) }; return(View(usersVM)); }
public ActionResult Register(UsersVM user) { if (ModelState.IsValid) { userbll.AddUser(user); } List <qualificationVM> lstQualifications = qualificationbll.getQualifications(); SelectList QualificationList = new SelectList(lstQualifications, "qualification_id", "qualification_name"); ViewBag.QualificationList = QualificationList; return(View()); }
public ActionResult Edit(int uId) { var userTypesList = _userTypesService.GetAll(); var model = new UsersVM { User = _usersService.GetById(uId), UserTypes = userTypesList }; return(View(model)); }
public ActionResult Users() { List <UserDM> users = _mappers.ToUserDM.Map <IEnumerable <UserDTO>, List <UserDM> >(_service.StoreService.GetUsers()); List <ClientProfileDM> clients = _mappers.ToClientProfileDM.Map <IEnumerable <ClientProfileDTO>, List <ClientProfileDM> >(_service.StoreService.GetClients()); UsersVM usersModel = new UsersVM() { Clients = clients, Users = users }; return(View(usersModel)); }
public static bool Insert(Guid id, string fname, string lname, string mname, string add, string email, string pass, string cnum, bool isAllow, Guid areg, Guid profID, Guid dtid) { try { var data = UsersVM.set(id, fname, lname, mname, add, email, pass, cnum, isAllow, areg, profID, dtid); using (var context = new CentralProcessContext()) { context.UsersDB.Add(data); context.SaveChanges(); return(true); } } catch { return(false); } }
public ActionResult Edit([Bind(Include = "Id,Email,RoleName")] UsersVM user, string RoleId) { if (ModelState.IsValid) { var userItem = _db.Users.FirstOrDefault(u => u.Id == user.Id); userItem.RoleId = RoleId; _db.Entry(userItem).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create() { var userTypesList = _userTypesService.GetAll(); var model = new UsersVM { User = new Users(), UserTypes = userTypesList }; return(View(model)); }