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> NewSponsor([FromForm] Sponsor sponsor) { BaseResult <SponsorModel> baseResult = new BaseResult <SponsorModel>(); int userId = Convert.ToInt32(HttpContext.User.Identity.Name); sponsor.creatorId = userId; bool isSuccess = false; string user = GetUserClaims("user"); if (!String.IsNullOrEmpty(user)) { User userObject = JsonConvert.DeserializeObject <User>(user); sponsor.statusId = userObject.userTypeId == (int)enumUserType.doctor ? 2 : 3; string bucketName = _SMethod.GetEnumValue(enumBucketType.Sponsors); IFormFile logoFile = sponsor.logoFile.FirstOrDefault(); string logoPath = await _SMinio.UploadFile(bucketName, logoFile); if (!String.IsNullOrEmpty(logoPath)) { sponsor.logoPath = logoPath; sponsor.id = _SSponsor.Insert(sponsor); if (sponsor.id > 0) { baseResult.data.sponsor = sponsor; baseResult.errMessage = sponsor.statusId == 2 ? "Sponsor Başarıyla Eklendi!" : "Sponsor Eklendi Yönetici Onayı Beklemektedir!"; isSuccess = true; } else { baseResult.errMessage = "Sponsor Oluşturulamadı!"; baseResult.statusCode = HttpStatusCode.NotFound; } } else { baseResult.errMessage = "Sponsor Logosu Yüklenemedi!"; baseResult.statusCode = HttpStatusCode.NotFound; } } if (isSuccess) { return(Json(baseResult)); } else { return(new NotFoundObjectResult(baseResult)); } }
public async Task <IActionResult> NewEvent([FromForm] Event _event) { BaseResult <EventModel> baseResult = new BaseResult <EventModel>(); int userId = Convert.ToInt32(HttpContext.User.Identity.Name); User user = _SUser.GetById(userId); bool isSuccess = false; if (user.eventCount > 0) { _event.userId = Convert.ToInt32(HttpContext.User.Identity.Name); string bucketName = _SMethod.GetEnumValue(enumBucketType.Events); IFormFile logoFile = _event.logoFiles.FirstOrDefault(); string path = await _SMinio.UploadFile(bucketName, logoFile); if (!String.IsNullOrEmpty(path)) { _event.logoPath = path; _event.creatorId = userId; _event.id = _SEvent.Insert(_event); baseResult.data.cgevent = _event; isSuccess = _event.id > 0 ? true : false; } else { baseResult.errMessage = "Logo Yüklenemedi!"; } } else { baseResult.errMessage = "Etkinlik Oluşturma Hakkınız Bulunmuyor!"; } if (isSuccess) { user.eventCount--; _SUser.UpdateUser(user); return(Json(baseResult)); } else { baseResult.statusCode = HttpStatusCode.NotFound; return(new NotFoundObjectResult(baseResult)); } }