public async Task <IActionResult> NewBusiness([FromBody] User user) { BaseResult <UserModel> baseResult = new BaseResult <UserModel>(); int userId = Convert.ToInt32(HttpContext.User.Identity.Name); user.creatorId = userId; bool isSuccess = false; User _user = _SUser.CheckUser(user.email); if (String.IsNullOrEmpty(_user.email)) { user.gender = (int)enumGenderType.Belirtilmemiş; user.userGuid = Guid.NewGuid().ToString(); string password = ""; for (int i = 0; i < 8; i++) { password += user.userGuid[i].ToString(); } user.password = _SMethod.StringToMd5(password); user.userTypeId = (int)enumUserType.business; user.id = _SUser.InsertUser(user); if (user.id > 0) { EmailVerificationQueueModel emailVerificationQueueModel = new EmailVerificationQueueModel() { email = user.email, userGuid = user.userGuid }; PasswordQueueModel passwordQueueModel = new PasswordQueueModel() { email = user.email, password = password }; await notificationDispatcher.SendEmailVerification(emailVerificationQueueModel); await notificationDispatcher.SendPassword(passwordQueueModel); isSuccess = true; baseResult.data.user = user; } else { baseResult.errMessage = "Firma Oluşturulamadı!"; } } else { baseResult.errMessage = "Bu Bilgilerde Bir Firma Zaten Mevcut"; } if (isSuccess) { return(Json(baseResult)); } else { baseResult.statusCode = HttpStatusCode.NotFound; return(new NotFoundObjectResult(baseResult)); } }
public async Task <IActionResult> Register([FromForm] User user) { BaseResult <UserModel> baseResult = new BaseResult <UserModel>(); bool isSuccess = false; User _user = _SUser.CheckUser(user.email); if (String.IsNullOrEmpty(_user.email)) { string bucketName = _SMethod.GetEnumValue(enumBucketType.Avatars); IFormFile avatarFile = user.avatarFile.FirstOrDefault(); string avatarPath = await _SMinio.UploadFile(bucketName, avatarFile); if (!String.IsNullOrEmpty(avatarPath)) { user.avatarPath = avatarPath; int userTypeId = Convert.ToInt32(_SMethod.GetEnumValue(enumUserType.user)); user.userTypeId = userTypeId; user.password = _SMethod.StringToMd5(user.password); user.userGuid = Guid.NewGuid().ToString(); user.taxNr = ""; user.id = _SUser.InsertUser(user); if (user.id > 0) { baseResult.errMessage = "Kayıt İşlemi Başarıyla Tamamlandı!"; isSuccess = true; EmailVerificationQueueModel emailVerificationQueueModel = new EmailVerificationQueueModel() { email = user.email, userGuid = user.userGuid }; await notificationDispatcher.SendEmailVerification(emailVerificationQueueModel); } else { baseResult.errMessage = "Kayıt Olunamadı!"; baseResult.statusCode = HttpStatusCode.NotFound; } } else { baseResult.errMessage = "Dosya Saklama Sunucusuna Ulaşılamadı!"; baseResult.statusCode = HttpStatusCode.NotFound; } } else { baseResult.errMessage = "Bu Bilgilere Ait Bir Hesap Var!"; baseResult.statusCode = HttpStatusCode.NotFound; } if (isSuccess) { return(Json(baseResult)); } else { return(new NotFoundObjectResult(baseResult)); } }
public async Task <IActionResult> Login([FromBody] User user) { bool isSuccess = false; BaseResult <UserModel> baseResult = new BaseResult <UserModel>(); string password = _SMethod.StringToMd5(user.password); User _user = _SUser.Login(user.email, password); if (_user != null) { if (_user.statusId == 2) { if (_user.emailVerification == 2) { if (_user.loginType == (int)enumLoginType.Phone && _user.userTypeId != (int)enumUserType.user) { baseResult.errMessage = "Normal Kullanıcı Dışındaki Kullanıcılar Mobil Uygulamayı Kullanamazlar"; } else { baseResult.data.user = _user; baseResult.data.menus = _SMenu.GetUserMenu(user.loginType, _user.userTypeId); string jsonUser = JsonConvert.SerializeObject(_user); baseResult.data.token = GenerateToken(_user.id.ToString(), jsonUser); isSuccess = true; } } else { baseResult.errMessage = "E-Postanızı Onaylamamışsınız! E-Posta Onaylama Maili Mail Kutunuza Tekrar Gönderildi!"; baseResult.statusCode = HttpStatusCode.NotFound; EmailVerificationQueueModel emailVerificationQueueModel = new EmailVerificationQueueModel() { email = _user.email, userGuid = _user.userGuid }; await notificationDispatcher.SendEmailVerification(emailVerificationQueueModel); } } else { baseResult.errMessage = "Kullanıcı Aktif Değil! Sistem Yöneticisiyle İletişime Geçiniz"; baseResult.statusCode = HttpStatusCode.NotFound; } } else { baseResult.errMessage = "Bu Bilgilere Ait Bir Kullanıcı Bulunamadı!"; baseResult.statusCode = HttpStatusCode.NotFound; } if (isSuccess) { return(Json(baseResult)); } else { return(new NotFoundObjectResult(baseResult)); } }
public async Task SendEmailVerification(EmailVerificationQueueModel model) { await this._hubContext.Clients.All.SendAsync("SendEmailVerification", model); }
public async Task <IActionResult> ImportEventParticipants([FromForm] EventParticipant eventParticipant) { BaseResult <UserModel> baseResult = new BaseResult <UserModel>(); bool isSuccess = false; List <User> users = _SUser.GetAllUser(); List <User> excelFileUsers = new List <User>(); List <EventParticipant> rels = new List <EventParticipant>(); Dictionary <string, string> hashedValue = new Dictionary <string, string>(); int id = Convert.ToInt32(HttpContext.User.Identity.Name); using (MemoryStream ms = new MemoryStream()) { IFormFile formFile = eventParticipant.importUserFile[0]; await formFile.CopyToAsync(ms); using (ExcelPackage excelPackage = new ExcelPackage(ms)) { var workSheet = excelPackage.Workbook.Worksheets.First(); int rowCount = workSheet.Dimension.End.Row; int userTypeId = Convert.ToInt32(_SMethod.GetEnumValue(enumUserType.user)); for (int row = 1; row <= rowCount; row++) { var emailAddress = workSheet.Cells[row, 1].Value; if (emailAddress != null) { bool emailVerification = _SMethod.ValidateEmail(emailAddress.ToString()); if (emailVerification) { User _user = new User(); string guid = Guid.NewGuid().ToString(); string _password = ""; for (int i = 0; i < 8; i++) { _password += guid[i]; } _user.email = emailAddress.ToString(); _user.name = _user.surname = ""; _user.avatarPath = ""; _user.phoneNr = _user.taxNr = ""; _user.userTypeId = userTypeId; _user.userGuid = Guid.NewGuid().ToString(); _user.identityNr = ""; _user.password = _SMethod.StringToMd5(_password); _user.emailVerification = 1; _user.profileStatus = 1; _user.notificationStatus = 2; _user.statusId = 2; _user.creationDate = _user.birthDate = DateTime.Now; _user.gender = Convert.ToInt32(_SMethod.GetEnumValue(enumGenderType.Belirtilmemiş)); if (excelFileUsers.FirstOrDefault(x => x.email.Equals(emailAddress)) == null) { excelFileUsers.Add(_user); hashedValue.TryAdd(emailAddress.ToString(), _password); } } } } List <User> usersNotIn = excelFileUsers.Where(x => !users.Any(y => y.email.Equals(x.email))).ToList(); foreach (var item in usersNotIn) { int userId = _SUser.InsertUser(item); rels.Add(new EventParticipant { eventId = eventParticipant.eventId, userId = userId, creatorId = id, creationDate = DateTime.Now, statusId = 2 }); string _password = ""; hashedValue.TryGetValue(item.email, out _password); if (!String.IsNullOrEmpty(_password)) { EmailVerificationQueueModel emailVerificationQueueModel = new EmailVerificationQueueModel() { email = item.email, userGuid = item.userGuid }; PasswordQueueModel passwordQueue = new PasswordQueueModel() { email = item.email, password = _password }; await notificationDispatcher.SendPassword(passwordQueue); await notificationDispatcher.SendEmailVerification(emailVerificationQueueModel); } } List <User> usersIn = excelFileUsers.Where(x => users.Any(y => y.email.Equals(x.email))).ToList(); foreach (var item in usersIn) { rels.Add(new EventParticipant { eventId = eventParticipant.eventId, userId = item.id, creatorId = id, creationDate = DateTime.Now, statusId = 2 }); } List <User> participants = new List <User>(); participants.AddRange(usersNotIn); participants.AddRange(usersIn); isSuccess = _SEventParticipant.BulkInsertParticipants(rels); baseResult.data.users = participants; } } if (isSuccess) { return(Json(baseResult)); } else { baseResult.statusCode = HttpStatusCode.NotFound; return(new NotFoundObjectResult(baseResult)); } }