public async Task <bool> AddUserInfo(UserInfoTable userinfo) { string query = "insert into user(user_id, user_name,user_pwd,user_phone,user_gender,user_flag,create_time,update_time) values(@user_id,@user_name,@user_pwd,@user_phone,@user_gender,@user_flag,@create_time,@update_time)"; int row = await _dbContext.Update <UserInfoTable>(query, userinfo); return(row > 0 ? true : false); }
public async Task <bool> UpdateUserInfo(UserInfoTable userinfo) { var sql = string.Format("update user_info set user_name=@userName,user_pwd=@userPwd,user_phone=@userPhone,user_gender=@userGender,user_flag=@userFlag,create_time=@createTime,update_time=@updateTime where user_id=@userId"); var row = await _dbContext.Update <UserInfoTable>(sql, userinfo); return(row > 0 ? true : false); }
public ActionResult Register(UserViewModel userView) { if (ModelState.IsValid) { var UserAccount = new UserTable(); UserAccount.UserName = userView.UserName1; UserAccount.U_Pwd = userView.UserPassword1; UserAccount.RoleID = 2; var UserInfo = new UserInfoTable(); UserInfo.FirstName = userView.FirstName1; UserInfo.LastName = userView.LastName1; UserInfo.UserID = UserAccount.UserID; UserInfo.U_Email = userView.U_Email1; UserInfo.U_PhoneNumber = userView.U_PhoneNumber1; UserInfo.U_Address = userView.U_Address1; db.UserTables.Add(UserAccount); db.UserInfoTables.Add(UserInfo); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } else { return(View(userView)); } }
public AuthenticationResponse RegisterWithSocialLogin(UserRegistrationModel userRegistrationModel) { UserInfoTableDto userInfoTableDto = new UserInfoTableDto { IAutoId = 0, VUserId = userRegistrationModel.VUserId, VFullName = userRegistrationModel.VFullName, DDateOfBirth = userRegistrationModel.DDateOfBirth, VPassword = userRegistrationModel.VPassword, BIsActive = true }; AuthenticationResponse authenticationResponse = new AuthenticationResponse(); var userEntity = _context.UserInfoTable.FirstOrDefault(x => x.VUserId.Equals(userInfoTableDto.VUserId)); if (userEntity != null) //Check if this userid already exists in the system... { UserInfoTableDto userDto = _mapper.Map <UserInfoTableDto>(userEntity); authenticationResponse = new AuthenticationResponse { isAuthenticated = true, isRegistrationSucceed = true, vMessage = "User Already Registered, Login Successfull!", userObj = userDto }; } else { // New User Registration... UserInfoTable userObj = _mapper.Map <UserInfoTable>(userInfoTableDto); _context.UserInfoTable.Add(userObj); var res = _context.SaveChanges(); if (res > 0) // New Us\er Registration entry succeed... { UserInfoTableDto newUserObj = _mapper.Map <UserInfoTableDto>(userObj); authenticationResponse = new AuthenticationResponse { isAuthenticated = true, isRegistrationSucceed = true, vMessage = "SignUp Successfull!!", userObj = newUserObj }; } else // New User Registration entry failed... { authenticationResponse = new AuthenticationResponse { isAuthenticated = false, isRegistrationSucceed = false, vMessage = "SignUp Failed!", userObj = null }; } } return(authenticationResponse); }
public int Insert <T>(T entity) { Type type = entity.GetType(); if (type == typeof(City)) { return(CityTable.Insert(entity as City)); } if (type == typeof(Customer)) { return(CustomerTable.Insert(entity as Customer)); } if (type == typeof(Distillation)) { return(DistillationTable.Insert(entity as Distillation)); } if (type == typeof(District)) { return(DistrictTable.Insert(entity as District)); } if (type == typeof(Material)) { return(MaterialTable.Insert(entity as Material)); } if (type == typeof(Period)) { return(PeriodTable.Insert(entity as Period)); } if (type == typeof(Region)) { return(RegionTable.Insert(entity as Region)); } if (type == typeof(Reservation)) { return(ReservationTable.Insert(entity as Reservation)); } if (type == typeof(Season)) { return(SeasonTable.Insert(entity as Season)); } if (type == typeof(UserInfo)) { return(UserInfoTable.Insert(entity as UserInfo)); } return(0); }
public ICollection <T> SelectAll <T>(T type) where T : new() { Type entType = type.GetType(); if (entType == typeof(City)) { return((ICollection <T>)CityTable.Select()); } if (entType == typeof(Customer)) { return((ICollection <T>)CustomerTable.Select()); } if (entType == typeof(Distillation)) { return((ICollection <T>)DistillationTable.Select()); } if (entType == typeof(District)) { return((ICollection <T>)DistrictTable.Select()); } if (entType == typeof(Material)) { return((ICollection <T>)MaterialTable.Select()); } if (entType == typeof(Period)) { return((ICollection <T>)PeriodTable.Select()); } if (entType == typeof(Region)) { return((ICollection <T>)RegionTable.Select()); } if (entType == typeof(Reservation)) { return((ICollection <T>)ReservationTable.Select()); } if (entType == typeof(Season)) { return((ICollection <T>)SeasonTable.Select()); } if (entType == typeof(UserInfo)) { return((ICollection <T>)UserInfoTable.Select()); } return(null); }
public T Select <T>(T type, int primaryKey) where T : new() { Type entType = type.GetType(); if (entType == typeof(City)) { return((T)Convert.ChangeType(CityTable.Select(primaryKey), typeof(T))); } if (entType == typeof(Customer)) { return((T)Convert.ChangeType(CustomerTable.Select(primaryKey), typeof(T))); } if (entType == typeof(Distillation)) { return((T)Convert.ChangeType(DistillationTable.Select(primaryKey), typeof(T))); } if (entType == typeof(District)) { return((T)Convert.ChangeType(DistrictTable.Select(primaryKey), typeof(T))); } if (entType == typeof(Material)) { return((T)Convert.ChangeType(MaterialTable.Select(primaryKey), typeof(T))); } if (entType == typeof(Period)) { return((T)Convert.ChangeType(PeriodTable.Select(primaryKey), typeof(T))); } if (entType == typeof(Region)) { return((T)Convert.ChangeType(RegionTable.Select(primaryKey), typeof(T))); } if (entType == typeof(Reservation)) { return((T)Convert.ChangeType(ReservationTable.Select(primaryKey), typeof(T))); } if (entType == typeof(Season)) { return((T)Convert.ChangeType(SeasonTable.Select(primaryKey), typeof(T))); } if (entType == typeof(UserInfo)) { return((T)Convert.ChangeType(UserInfoTable.Select(primaryKey), typeof(T))); } return(default(T)); }
public ActionResult Remove(int id) { UserInfoTable UserInfo = db.UserInfoTables.Find(id); UserTable UserAccount = db.UserTables.Find(id); db.UserInfoTables.Remove(UserInfo); db.UserTables.Remove(UserAccount); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult Edit(int id) { if (ModelState.IsValid) { UserInfoTable UserInfo = db.UserInfoTables.Find(id); if (TryUpdateModel(UserInfo, "", new string[] { "FirstName", "LastName", "U_Email", "U_PhoneNumber", "U_Address" })) { db.SaveChanges(); return(RedirectToAction("Index", "Home")); } } return(RedirectToAction("Index", "Home")); }
public ActionResult Remove(int?id) { if (Convert.ToBoolean(Session["IsAdmin"]) == true) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserInfoTable User = db.UserInfoTables.Find(id); if (User == null) { return(HttpNotFound()); } return(View(User)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult Detail(int?id) { var UserID = (from User in db.UserInfoTables where User.UserID == id select User.UserID).SingleOrDefault(); if (Convert.ToInt32(Session["UserID"]) == id || Convert.ToBoolean(Session["IsAdmin"]) == true) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserInfoTable UserInfo = db.UserInfoTables.Find(id); if (UserInfo == null) { return(HttpNotFound()); } return(View(UserInfo)); } else { return(RedirectToAction("Index", "Home")); } }
/// <summary> /// Insert new row of user information in the database /// </summary> /// <param name="userInfo">The user information of type UserInfoTable</param> public void InsertTable(UserInfoTable userInfo) { db.Insert(userInfo); }