public ResponseViewModel <UserRegisterResponseViewModel> GetById(long userId) { ResponseViewModel <UserRegisterResponseViewModel> response = new ResponseViewModel <UserRegisterResponseViewModel>(); List <Error> lstError = new List <Error>(); UserRegisterResponseViewModel objUserResponseViewModel = new UserRegisterResponseViewModel(); try { var finduser = _userRepository.Find(userId); if (finduser != null) { string birthDate = string.Empty; if (finduser.BirthDate != null) { birthDate = string.Format("{0:yyyy-MM-ddTHH:mm:ssZ}", finduser.BirthDate); } objUserResponseViewModel = new UserRegisterResponseViewModel() { userid = userId, address = finduser.Address, birthdate = birthDate, contactnumber = finduser.ContactNumber, email = finduser.Email, firstname = finduser.FirstName, lastname = finduser.LastName, status = finduser.Status, usertype = finduser.UserType }; } else { var errorMessage = _errorMessageService.GetErrorMessagesData("2020"); errorMessage = errorMessage.Replace("$$InputData$$", "User"); var objError = new Error { Code = "2020", Message = errorMessage }; lstError.Add(objError); } if (lstError.Count == 0) { response.Status = true; response.Message = "User get sucessfully"; response.StatusCode = (int)HttpStatusCode.OK; response.Result = objUserResponseViewModel; } else { response.Status = false; response.Errors = lstError; response.StatusCode = (int)HttpStatusCode.BadRequest; } } catch (Exception ex) { if (ex.InnerException != null) { _loggerService.LogError(1, "## [UserService][GetById] innerexception :" + ex.InnerException.ToString()); if (ex.InnerException.Message != null) { _loggerService.LogError(1, "## [UserService][GetById] innerexception message :" + ex.InnerException.Message.ToString()); } } else { _loggerService.LogError(1, "## [UserService][GetById] exception :" + ex.Message.ToString()); } response.Status = false; response.Message = _errorMessageService.GetErrorMessagesData("501"); response.StatusCode = (int)HttpStatusCode.BadRequest; } return(response); }
public ResponseViewModel <List <UserRegisterResponseViewModel> > GetAll() { ResponseViewModel <List <UserRegisterResponseViewModel> > response = new ResponseViewModel <List <UserRegisterResponseViewModel> >(); List <UserRegisterResponseViewModel> _lstUserResponse = new List <UserRegisterResponseViewModel>(); try { var _lstUser = _userRepository.GetAll().ToList(); for (int i = 0; i < _lstUser.Count; i++) { string birthDate = string.Empty; if (_lstUser[i].BirthDate != null) { birthDate = string.Format("{0:yyyy-MM-ddTHH:mm:ssZ}", _lstUser[i].BirthDate); } UserRegisterResponseViewModel _objUserResponse = new UserRegisterResponseViewModel() { userid = _lstUser[i].UserId, address = _lstUser[i].Address, birthdate = birthDate, contactnumber = _lstUser[i].ContactNumber, email = _lstUser[i].Email, firstname = _lstUser[i].FirstName, lastname = _lstUser[i].LastName, status = _lstUser[i].Status, usertype = _lstUser[i].UserType }; _lstUserResponse.Add(_objUserResponse); } if (_lstUserResponse.Count > 0) { response.Status = true; response.Message = _errorMessageService.GetErrorMessagesData("116"); response.Result = _lstUserResponse; } else { response.Status = false; response.Message = _errorMessageService.GetErrorMessagesData("117"); response.Result = _lstUserResponse; } } catch (Exception ex) { if (ex.InnerException != null) { _loggerService.LogError(1, "## [UserService][GetAll] innerexception :" + ex.InnerException.ToString()); if (ex.InnerException.Message != null) { _loggerService.LogError(1, "## [UserService][GetAll] innerexception message :" + ex.InnerException.Message.ToString()); } } else { _loggerService.LogError(1, "## [UserService][GetAll] exception :" + ex.Message.ToString()); } response.Status = false; response.Message = _errorMessageService.GetErrorMessagesData("501"); response.StatusCode = (int)HttpStatusCode.BadRequest; } return(response); }
private async void uploadMedia(string filePath, string mediaType, UserRegisterResponseViewModel model) { var mediaName = System.IO.Path.GetFileName(filePath); //AWSUploader.SetMediaName (mediaType); var url = ""; try { // BTProgressHUD.Show("Processing media..", maskType: ProgressHUD.MaskType.Black); if (mediaType == "Photo") { await AWSUploader.AWSUploadImage(filePath, mediaName); } else { await AWSUploader.AWSUploadAudioVideo(filePath, mediaName, mediaType); } url = AWSUploader.GetMediaUrl(mediaType) + mediaName; try { if (string.IsNullOrEmpty(url)) { //Toast.MakeText(this, "Check Your Internet Connection", ToastLength.Long).Show(); } else { var Result = await new AccountService().Registration(new UserRegisterRequestViewModel { Email = model.Email, Password = model.Password, ZipCode = model.ZipCode, City = model.City, State = model.State, Country = model.Country, AboutMe = model.AboutMe, ProfileImageUrl = url, }, GlobalConstant.AccountUrls.RegisterServiceUrl); if (Result.Status == 1) { var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString()); var UserprofileRepo = UserProfileRepository.GetUserProfile(CommonHelper.GetUserId()); UserprofileRepo.ZipCode = modelReporeg.ZipCode; UserprofileRepo.City = modelReporeg.City; UserprofileRepo.State = modelReporeg.State; UserprofileRepo.Country = modelReporeg.Country; UserprofileRepo.AboutMe = modelReporeg.AboutMe; UserprofileRepo.ProfileImageUrl = modelReporeg.ProfileImageUrl; UserProfileRepository.UpdateUserProfile(UserprofileRepo); new UIAlertView("Update Your Profile", "Profile Updated Successfully", null, "OK", null).Show(); BTProgressHUD.Dismiss(); this.DismissViewController(true, null); } } } catch (Exception e) { Crashes.TrackError(e); BTProgressHUD.Dismiss(); new UIAlertView("Error", e.ToString(), null, "OK", null).Show(); //Toast.MakeText(this, e.Message, ToastLength.Long).Show(); } } catch (Exception e) { Crashes.TrackError(e); BTProgressHUD.Dismiss(); new UIAlertView("Error", e.ToString(), null, "OK", null).Show(); //Toast.MakeText(this, e.Message, ToastLength.Long).Show(); } }
public ResponseViewModel <UserRegisterResponseViewModel> CreateUser(UserRegisterRequestViewModel inputModel) { ResponseViewModel <UserRegisterResponseViewModel> response = new ResponseViewModel <UserRegisterResponseViewModel>(); List <Error> lstError = new List <Error>(); UserRegisterResponseViewModel objUserResponseViewModel = new UserRegisterResponseViewModel(); try { _loggerService.LogInformation(1, "## [UserService][CreateUser]- Start CreateUser user method."); var finduser = _userRepository.FindByEmail(inputModel.email); if (finduser == null) { byte[] passwordHash, passwordSalt; _securityHelper.CreatePasswordHash(inputModel.password, out passwordHash, out passwordSalt); Users objuser = new Users() { Address = inputModel.address, BirthDate = DateTimeOffset.Parse(inputModel.birthdate).UtcDateTime, ContactNumber = inputModel.contactnumber, Email = inputModel.email, FirstName = inputModel.firstname, LastName = inputModel.lastname, Status = inputModel.status, UserType = inputModel.usertype, PasswordHash = passwordHash, PasswordSalt = passwordSalt, CreatedBy = inputModel.createdby, UpdatedBy = inputModel.createdby, CreatedOn = DateTime.UtcNow, UpdatedOn = DateTime.UtcNow }; _loggerService.LogInformation(1, "## [UserService][CreateUser]- Create User Model Email : " + objuser.Email + " , FirstName : " + objuser.FirstName + " , LastName : " + objuser.LastName); var userId = _userRepository.Add(objuser); if (userId > 0) { string birthDate = Convert.ToString(inputModel.birthdate); objUserResponseViewModel = new UserRegisterResponseViewModel() { userid = userId, address = inputModel.address, birthdate = string.Format("{0:yyyy-MM-ddTHH:mm:ssZ}", birthDate), contactnumber = inputModel.contactnumber, email = inputModel.email, firstname = inputModel.firstname, lastname = inputModel.lastname, status = inputModel.status, usertype = inputModel.usertype }; _loggerService.LogInformation(1, "## [UserService][CreateUser]- User created sucessfully : " + objUserResponseViewModel.email); } else { _loggerService.LogInformation(1, "## [UserService][CreateUser]- User not created in userRepository for email id : " + inputModel.email); var errorMessage = _errorMessageService.GetErrorMessagesData("2020"); var objError = new Error { Code = "2020", Message = errorMessage }; lstError.Add(objError); } } else { _loggerService.LogInformation(1, "## [UserService]-[CreateUser]- User already exists "); var errorMessage = _errorMessageService.GetErrorMessagesData("2020"); errorMessage = errorMessage.Replace("$$InputData$$", "User"); var objError = new Error { Code = "2020", Message = errorMessage }; lstError.Add(objError); } if (lstError.Count == 0) { response.Status = true; response.Message = "User Created Sucessfully"; response.StatusCode = (int)HttpStatusCode.OK; response.Result = objUserResponseViewModel; } else { response.Status = false; response.Errors = lstError; response.StatusCode = (int)HttpStatusCode.BadRequest; } } catch (Exception ex) { if (ex.InnerException != null) { _loggerService.LogError(1, "## [UserService][CreateUser] innerexception :" + ex.InnerException.ToString()); if (ex.InnerException.Message != null) { _loggerService.LogError(1, "## [UserService][CreateUser] innerexception message :" + ex.InnerException.Message.ToString()); } } else { _loggerService.LogError(1, "## [UserService][CreateUser] exception :" + ex.Message.ToString()); } response.Status = false; response.Message = _errorMessageService.GetErrorMessagesData("501"); response.StatusCode = (int)HttpStatusCode.BadRequest; return(response); } return(response); }
private async void uploadMedia(string filePath, string mediaType, UserRegisterResponseViewModel model) { var mediaName = System.IO.Path.GetFileName(filePath); //AWSUploader.SetMediaName (mediaType); var url = ""; try { // BTProgressHUD.Show("Processing media..", maskType: ProgressHUD.MaskType.Black); if (mediaType == "Photo") { await AWSUploader.AWSUploadImage(filePath, mediaName); } else { await AWSUploader.AWSUploadAudioVideo(filePath, mediaName, mediaType); } url = AWSUploader.GetMediaUrl(mediaType) + mediaName; try { if (string.IsNullOrEmpty(url)) { Toast.MakeText(this, "Check Your Internet Connection", ToastLength.Long).Show(); } else { var Result = await new AccountService().Registration(new UserRegisterRequestViewModel { Email = model.Email, Password = model.Password, ZipCode = model.ZipCode, City = model.City, State = model.State, Country = model.Country, AboutMe = model.AboutMe, ProfileImageUrl = url, }, GlobalConstant.AccountUrls.RegisterServiceUrl); if (Result.Status == 1) { var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString()); var UserprofileRepo = UserProfileRepository.GetUserProfile(CommonHelper.GetUserId()); UserprofileRepo.ZipCode = modelReporeg.ZipCode; UserprofileRepo.City = modelReporeg.City; UserprofileRepo.State = modelReporeg.State; UserprofileRepo.Country = modelReporeg.Country; UserprofileRepo.AboutMe = modelReporeg.AboutMe; UserprofileRepo.ProfileImageUrl = modelReporeg.ProfileImageUrl; UserProfileRepository.UpdateUserProfile(UserprofileRepo); Toast.MakeText(this, "Profile Complete Successfully", ToastLength.Short).Show(); CommonHelper.DismissProgressBar(this); this.Finish(); var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.SingleTop); StartActivity(intent); } } } catch (Java.Lang.Exception e) { Toast.MakeText(this, e.Message, ToastLength.Long).Show(); } } catch (Java.Lang.Exception e) { Toast.MakeText(this, e.Message, ToastLength.Long).Show(); } }