public ActionResult Add(User u) { var ctx = new UserModel(); ctx.Add(u); return(RedirectToAction("Index")); }
public async Task <IActionResult> Login([FromBody] LoginModel loginInfo) { if (string.IsNullOrWhiteSpace(loginInfo.Username)) { return(await GenericResponse(ResponseType.InvalidModel, "Username is required")); } var errMsg = string.Empty; var user = EnergoServer.Current.Login(loginInfo.Username, out errMsg); return(await GenericResponse(() => { ServerContext.Current.Chat.AddChannel(user, ChatChannelType.Private, user.Id); var broadcast = new UserModel(user).GetInfo(new UserModelViewOptions() { Id = true, Name = true }).AddItem(BroadcastReason, Request.Path.Value); ServerContext.Current.DuplexNetwork.Broadcast(broadcast); var obj = new UserModel(user).GetInfo(new UserModelViewOptions() { Id = true, Name = true }); obj.Add("AuthToken", user.AuthToken); return obj; }, errMsg, ResponseType.InvalidModel).Invoke()); }
/// <summary> /// 创建角色 /// </summary> /// <param name="client">连接对象</param> /// <param name="name">角色名</param> /// <param name="accountId">账号id</param> public void Create(string name, int accountId) { UserModel model = new UserModel(); model.Name = name; model.AccountId = accountId; model.Add(); //保存到字典里 idModelDict.Add(model.Id, model); accIdUIdDict.Add(accountId, model.Id); }
public IActionResult Create([FromBody] UserItem item) { if (item == null) { return(BadRequest()); } userModel.Add(item); return(CreatedAtRoute("GetUser", new { id = item.Id }, item)); }
public String Add() { String message = ""; if (Valid()) { message = _userModel.Add(); } else { message = "Pengisian data kurang lengkap"; } return(message); }
public void AddTest() { var newuser = new User() { Login = "******", Pass = "******", UserType = 0 }; UserModel usermodel = new UserModel(); usermodel.Add(newuser); using (var db = new ElJournalDbContext()) { var finduser = db.Users.FirstOrDefault(u => u.Login == "vlad" && u.Pass == "123" && u.UserType == 0); Assert.AreNotEqual(null, finduser); } }
public ActionResult Registration(UserModel model) { if (ModelState.IsValid) { //Email is already Exist var isEmailExist = _userModel.IsEmailExist(model); if (isEmailExist) { ModelState.AddModelError("Email", "Email already exist"); return(View(model)); } var isSaved = model.Add(); if (isSaved) { return(RedirectToAction("Login")); } } return(View(model)); }
public virtual ActionResult Add(UserModel model) { if (ModelState.IsValid) { Status status; if (model.Add(out status)) { ModelState.AddModelError("Error", "Successfully created new system user!"); } else { ModelState.AddModelError("Error", status.Message()); } } else { ModelState.AddModelError("Error", "Please update the required fields!"); } model.UpdateUserModelForAdd(); return(View(model)); }
public ActionResult Register(RegisterModel registerInfo, string returnUrl) { if (User.Identity.IsAuthenticated == false) { return(RedirectToAction("index", "meeting")); } if (ModelState.IsValid) { if (Session["ValidateCode"] == null || registerInfo.ValidateCode.ToLower() != Session["ValidateCode"].ToString().ToLower()) { ModelState.AddModelError("ValidateCode", "验证码错误"); return(View(registerInfo)); } UserModel userModel = new UserModel(); user_info userInfo = new user_info(); userInfo.ui_name = registerInfo.UserName; userInfo.ui_password = userModel.PasswordEncrypt(registerInfo.Password); userInfo.ui_email = registerInfo.Email; userInfo.ui_grade_id = 1; userInfo.ui_create_time = DateTime.Now; userInfo.ui_status = true; userModel.Add(userInfo); //userModel.SignIn(userInfo, false); } if (!string.IsNullOrWhiteSpace(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Meeting")); }
public string AddUser(User user) { var result = UserModel.Add(user); return(JsonConvert.SerializeObject(result)); }