public UserInformationEntity Post(UserInformationEntity userInfoInsert) { try { UserInformationEntity inserteduserInfo = new UserInformationEntity(); UserInformation userInfoToInsert = MapEntities.Map <UserInformationEntity, UserInformation>(userInfoInsert); UserInformation existingUserInfo = new UserInformation(); existingUserInfo = userInformatinOperations.CheckUserInformationExistByUserName(userInfoToInsert.UserName); if (existingUserInfo != null && existingUserInfo.UserID > 0) { inserteduserInfo = MapEntities.Map <UserInformation, UserInformationEntity>(existingUserInfo); inserteduserInfo.ErrorMessage = "User Already Exists"; } else { userInfoToInsert = userInformatinOperations.InsertUserInformation(userInfoToInsert); inserteduserInfo = MapEntities.Map <UserInformation, UserInformationEntity>(userInfoToInsert); } return(inserteduserInfo); } catch (Exception ex) { throw ex; } }
public UserInformationEntity PostUserInfo(UserInformationEntity userInfoInsert) { try { UserInformation userInfo = userInformatinOperations.GetUserInformationuserNameAndPassword(userInfoInsert.UserName, userInfoInsert.Password); if (userInfo != null) { UserInformationEntity userInfoEntity = MapEntities.Map <UserInformation, UserInformationEntity>(userInfo); userInfoEntity.UserID = userInfo.UserID; userInfoEntity.UserName = userInfo.UserName; userInfoEntity.UserTypeID = userInfo.UserTypeID; //userInfoEntity.UserType.TypeName = userInfo.UserType.TypeName; userInfoEntity.Password = userInfo.Password; userInfoEntity.MobileNumber = userInfo.MobileNumber; return(userInfoEntity); } else { return(null); } } catch (Exception ex) { return(null); } }
/// <summary> /// Edit user profile Post /// </summary> public ActionResult EditProfile(EditUserInformation information, HttpPostedFileBase uploadImage) { UserInformationEntity profile = null; try { profile = _informationServiceService.GetByUserId(_userService.GetUserByName(User.Identity.Name).Id); } catch { return(RedirectToAction("Error", "Error")); } byte[] imageData = null; using (var binaryReader = new BinaryReader(uploadImage.InputStream)) { imageData = binaryReader.ReadBytes(uploadImage.ContentLength); } profile.Avatar = imageData; profile.FirstName = information.FirstName ?? profile.FirstName; profile.LastName = information.LastName ?? profile.LastName; profile.Age = information.Age == 0 ? profile.Age : information.Age; _informationServiceService.Update(profile); return(RedirectToAction("ShowProfile", new { userName = User.Identity.Name })); }
public async Task UpdateUserInformationAsync(UserInformationEntity userInformationEntity, UserInformationModel userInformationModel) { userInformationEntity.Department.Id = userInformationModel.Department.Id; userInformationEntity.Addres = userInformationModel.Addres; userInformationEntity.DateOfBirth = userInformationModel.DateOfBirth; userInformationEntity.About = userInformationModel.About; await _userInformationRepository.SaveAsync(); }
public void Update(UserInformationEntity information) { if (ReferenceEquals(information, null)) { throw new ArgumentNullException(nameof(information)); } informationRepository.Update(information.ToDalInformationUsers()); uow.Commit(); }
public static UserInformationViewModel ToMVCInformationUsers(this UserInformationEntity information) { return(new UserInformationViewModel { Id = information.Id, Age = information.Age, Avatar = information.Avatar, FirstName = information.FirstName, LastName = information.LastName, UserId = information.UserId }); }
public static DalInformationUsers ToDalInformationUsers(this UserInformationEntity information) { return(new DalInformationUsers { Id = information.Id, Age = information.Age, Avatar = information.Avatar, FirstName = information.FirstName, LastName = information.LastName, UserId = information.UserId }); }
// PUT: api/FarmerDetail/5 public UserInformationEntity Put(UserInformationEntity userInfoUpdated) { try { UserInformation userInfoToUpdate = MapEntities.Map <UserInformationEntity, UserInformation>(userInfoUpdated); userInfoToUpdate = userInformatinOperations.UpdateUserInformation(userInfoToUpdate); return(MapEntities.Map <UserInformation, UserInformationEntity>(userInfoToUpdate)); } catch (Exception ex) { throw ex; } }
public async Task <UserInformationEntity> CreateUserInformationAsync(Guid userId, UserInformationModel userInformationModel) { var userInformationEntity = new UserInformationEntity { UserId = userId, Addres = userInformationModel.Addres, DateOfBirth = userInformationModel.DateOfBirth, About = userInformationModel.About, DepartmentId = userInformationModel.Department.Id }; await _userInformationRepository.CreateAsync(userInformationEntity); await _userInformationRepository.SaveAsync(); return(userInformationEntity); }
private bool SetLoggedOnUser(ActionExecutingContext context) { int userTypeID = SessionManager.UserTypeID; if (userTypeID == 0 || SessionManager.UserName == string.Empty) { context.Result = new RedirectResult("/OceanAgro/Login/Logout"); return(false); } LoggedonUser = new UserInformationEntity(); if (string.IsNullOrWhiteSpace(SessionManager.UserName) == false) { LoggedonUser.UserTypeID = SessionManager.UserTypeID; LoggedonUser.UserName = SessionManager.UserName; } return(true); }
/// <summary> /// 언어 정보 저장 /// </summary> public bool User_Image_Delete(UserInformationEntity pUserInformationEntity) { try { using (DBManager pDBManager = new DBManager()) { bool isReturn = new UserInformationProvider(pDBManager).User_Image_Delete(pUserInformationEntity); return(isReturn); } } catch (ExceptionManager pExceptionManager) { throw pExceptionManager; } catch (Exception pException) { throw new ExceptionManager(this, "User_Image_Delete(UserInformationEntity pUserInformationEntity)", pException); } }
/// <summary> /// 언어 정보 조회 /// </summary> public DataTable User_Info_Sub(UserInformationEntity pUserInformationEntity) { try { using (DBManager pDBManager = new DBManager()) { DataTable pDataTable = new UserInformationProvider(pDBManager).User_Info_Sub(pUserInformationEntity); return(pDataTable); } } catch (ExceptionManager pExceptionManager) { throw pExceptionManager; } catch (Exception pException) { throw new ExceptionManager(this, "User_Info_Sub(UserInformationEntity pUserInformationEntity)", pException); } }
// GET: api/UserInformationEntity/5 public UserInformationEntity Get(int userID) { try { UserInformation userInfo = userInformatinOperations.GetUserInformationByID(userID); UserInformationEntity userInfoEntity = MapEntities.Map <UserInformation, UserInformationEntity>(userInfo); userInfoEntity.UserID = userInfo.UserID; userInfoEntity.UserName = userInfo.UserName; userInfoEntity.UserTypeID = userInfo.UserTypeID; //userInfoEntity.UserType.TypeName = userInfo.UserType.TypeName; userInfoEntity.Password = userInfo.Password; userInfoEntity.MobileNumber = userInfo.MobileNumber; return(userInfoEntity); } catch (Exception ex) { throw ex; } }
public MembershipUser CreateUser(string name, string email, string password) //CREATE { var user = new UserEntity { Name = name, Email = email, Password = Crypto.HashPassword(password), Roles = new List <RoleEntity>(), Photos = new List <PhotoEntity>() }; user.Roles.Add(new RoleEntity { Name = "User" }); UserService.Create(user); var entity = new UserInformationEntity(); entity.UserId = UserService.GetUserByName(user.Name).Id; UserInformationService.Create(entity); return(GetUser(name, false)); }
public ActionResult Login(LoginViewModel model, string returnUrl) { try { if (!ModelState.IsValid) { return(View(model)); } ServiceInputObject serviceObject = new ServiceInputObject { baseURL = ConfigSettings.WebApiBaseAddress, controllerName = "UserInfo", methodName = "RetriveUserInfo" }; UserInformationEntity userInfo = new UserInformationEntity(); userInfo.UserName = model.UserName; userInfo.Password = model.Password; userInfo = ServiceMethods.GeneratePostRequest <UserInformationEntity>(userInfo, serviceObject); if (userInfo != null) { SessionManager.UserTypeID = userInfo.UserTypeID;; SessionManager.UserName = userInfo.UserName; SessionManager.UserId = userInfo.UserID; return(Redirect("~/Home/Index")); } else { ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } } catch (Exception) { ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public ActionResult Register(string registerformString) { if (ModelState.IsValid) { bool isSuccess = true; try { RegisterViewModel model = JsonConvert.DeserializeObject <RegisterViewModel>(registerformString); //var result = null ; ServiceInputObject serviceObject = new ServiceInputObject { baseURL = ConfigSettings.WebApiBaseAddress, controllerName = "UserInfo", parameterValue = string.Empty, methodName = "CreateAdminUser" }; UserInformationEntity userInfo = new UserInformationEntity(); userInfo.UserName = model.UserName; userInfo.EmailAddress = model.Email; userInfo.Password = model.Password; userInfo.MobileNumber = model.MobileNumber; userInfo.UserTypeID = (int)Enums.UserType.Admin; userInfo.CreatedDate = DateTime.Now.Date; UserInformationEntity insertedDetail = ServiceMethods.GeneratePostRequest <UserInformationEntity>(userInfo, serviceObject); if (string.IsNullOrWhiteSpace(insertedDetail.ErrorMessage)) { isSuccess = insertedDetail.UserID > 0; return(Json(new { success = isSuccess, ValidationMessages = "Admin Added" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, ValidationMessages = insertedDetail.ErrorMessage }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { //var result = ex; //AddErrors(result); return(Json(new { success = false, ValidationMessages = "Error" }, JsonRequestBehavior.AllowGet)); } //AddErrors(result); } return(Json(new { success = false, ValidationMessages = "Error" }, JsonRequestBehavior.AllowGet)); }