public void UpdateUser(SaveDataModel inputObject) { // Get LinQ var result = from tbl in EntityManager.Users where tbl.UserCd == PageHelper.UserCd && tbl.DeleteFlag == false select tbl; var resultSub = from tbl in EntityManager.Newsletters where tbl.Email == PageHelper.UserName select tbl; // Get entity var entity = result.SingleOrDefault(); var entitySub = resultSub.SingleOrDefault(); // Get system date var currentDate = DateTime.Now; // Setting value entity.FullName = inputObject.FullName; entity.HasNewsletter = inputObject.HasNewsletter; entity.UpdateUser = PageHelper.UserName; entity.UpdateDate = currentDate; if (inputObject.HasChangePassword) entity.Password = DataHelper.GetMd5Hash(inputObject.NewPassword); if (inputObject.HasNewsletter) { if (entitySub == null) { entitySub = new Newsletter(); entitySub.Email = PageHelper.UserName; entitySub.CreateUser = PageHelper.UserName; entitySub.CreateDate = currentDate; entitySub.UpdateUser = PageHelper.UserName; entitySub.UpdateDate = currentDate; entitySub.DeleteFlag = false; EntityManager.Newsletters.InsertOnSubmit(entitySub); } else { entitySub.UpdateUser = PageHelper.UserName; entitySub.UpdateDate = currentDate; entitySub.DeleteFlag = false; } } else { if(entitySub != null) entitySub.DeleteFlag = true; } // Submit EntityManager.SubmitChanges(); }
/// <summary> /// Execute convert input. /// </summary> /// <param name="request">RequestModel</param> /// <returns>DataModel</returns> private SaveDataModel Convert(SaveRequestModel request) { // Local variable declaration SaveDataModel inputObject = null; // Variable initialize inputObject = new SaveDataModel(); // Convert data input DataHelper.ConvertInput(request, inputObject); // Return value return inputObject; }
/// <summary> /// Execute convert ouput. /// </summary> /// <param name="resultObject">DataModel</param> /// <returns>ResponseModel</returns> private SaveResponseModel Convert(SaveDataModel resultObject) { // Local variable declaration SaveResponseModel responseModel = null; // Variable initialize responseModel = new SaveResponseModel(); // Get value var message = MessageHelper.GetMessageInfo("I_MSG_00001"); // Set value responseModel.AddMessage(message); // Return value return responseModel; }
/// <summary> /// Check processing. /// </summary> /// <param name="inputObject">DataModel</param> private void Check(SaveDataModel inputObject) { // Local variable declaration UserCom userCom = null; // Variable initialize userCom = new UserCom(); // Check valid if (!PageHelper.HasAuthenticated) throw new ExecuteException("E_MSG_00001", "Truy cập"); if (inputObject.HasChangePassword) { if (DataCheckHelper.IsNull(inputObject.Password)) throw new ExecuteException("E_MSG_00004", "Mật khẩu"); if (DataCheckHelper.IsNull(inputObject.NewPassword)) throw new ExecuteException("E_MSG_00004", "Mật khẩu mới"); if (!userCom.IsValidPassword(PageHelper.UserCd, inputObject.Password)) throw new ExecuteException("E_MSG_00001", "Mật khẩu"); if (inputObject.NewPassword != inputObject.NewPasswordConf) throw new ExecuteException("E_MSG_00001", "Mật khẩu và mật khẩu xác nhận"); } }
/// <summary> /// Save infomation /// </summary> /// <param name="inputObject">DataModel</param> /// <returns>DataModel</returns> private SaveDataModel SaveInfo(SaveDataModel inputObject) { // Local variable declaration SaveDataModel saveResult = null; ClientProfileDao clientProfileDao = null; // Variable initialize saveResult = new SaveDataModel(); clientProfileDao = new ClientProfileDao(); // Save data clientProfileDao.UpdateUser(inputObject); // Return value return saveResult; }