public async Task <IActionResult> MailService(DeclarationFormModel decModel, string uniqueId, string formId, string employeeName, IFormFile file) { employeeRepo.UploadFile(file, decModel.FormId); if (!await employeeRepo.UserIsEmployeeOrTrainee()) { return(AccessDeniedView()); } try { await declarationFormRepo.EditDeclarationForm(decModel); } catch (MoreThan24HoursException e) { return(RedirectToAction("HourReg", "DeclarationForm", new { declarationFormId = decModel.FormId, userId = decModel.EmployeeId, year = decModel.Year, month = decModel.Month, errorMessage = e.Message })); } await declarationFormRepo.SubmitDeclarationForm(decModel); await declarationFormRepo.CalculateTotalHours(decModel); //hier word mail opgesteld en verstuurd Mailservice.MailFormToClient(decModel, uniqueId, formId, employeeName); return(RedirectToRoute(new { controller = "Home", action = "Index" })); }
public async Task <IActionResult> Reject(int FormId, RejectFormModel rejectFormModel, string employeeName, string clientName) { var declarationFormModel = await declarationFormRepo.GetForm(FormId); var uniqueId = declarationFormModel.uniqueId; var comment = rejectFormModel.comment; if (ModelState.IsValid) { await declarationFormRepo.RejectForm(FormId, comment); //aanroepen mailservice afkeuren Mailservice.RejectMailToAdminAndEmployee(declarationFormModel, employeeName, clientName); return(View()); } else { return(RedirectToAction("ApproveOrReject", new { uniqueId = uniqueId, formId = FormId, commentNotValid = true })); } }
public VideoEncoder(Mailservice mailservice) { _mailservice = mailservice; }
// Remise // 0 -> error: couldn't find the user // 1 -> error: couldn't return the book // 2 -> success public int remise(int choice, int idOuvrage, int id) { var mailservice = new Mailservice(); remiseEmailSent += mailservice.OnremiseEmailSent; string user = ""; int ok = 0; conn.Open(); switch (choice) { case 1: { try { command.CommandText = "SELECT idUser FROM `etudiant` WHERE numeroCarte ='" + id + "'"; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { user = reader["idUser"].ToString(); ok = 1; } reader.Close(); if (ok == 1) { command.CommandText = " DELETE FROM emprunt WHERE idOuvrage = " + idOuvrage + " AND idUser = "******" UPDATE ouvrage" + " SET nbrExemplaireEmp = nbrExemplaireEmp - 1" + " WHERE idOuvrage = '" + idOuvrage + "'"; command.ExecuteNonQuery(); ok = 2; } } } catch (Exception ex) { Console.WriteLine(ex); } break; } case 2: { try { command.CommandText = "SELECT idUser FROM `enseignant` WHERE matricule ='" + id + "'"; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { user = reader["idUser"].ToString(); ok = 1; } reader.Close(); if (ok == 1) { command.CommandText = " DELETE FROM emprunt WHERE idOuvrage = " + idOuvrage + " AND idUser = "******" UPDATE ouvrage" + " SET nbrExemplaireEmp = nbrExemplaireEmp - 1" + " WHERE idOuvrage = '" + idOuvrage + "'"; command.ExecuteNonQuery(); ok = 2; } } } catch (Exception ex) { Console.WriteLine(ex); } break; } default: break; } if (ok == 2) { int o = 0; string idUser = ""; command.CommandText = "SELECT idUser FROM liste_attente where idOuvrage = '" + idOuvrage + "' order by idListe asc limit 1"; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { idUser = reader["idUser"].ToString(); o = 1; } reader.Close(); if (o == 1) { string email = ""; command.CommandText = "SELECT email FROM `user` WHERE idUser ="******"email"].ToString(); } reader.Close(); string title = ""; command.CommandText = "SELECT titre FROM `ouvrage` WHERE idOuvrage =" + idOuvrage; reader = command.ExecuteReader(); while (reader.Read()) { title = reader["titre"].ToString(); } reader.Close(); OnremiseEmailSent(email, title); command.CommandText = "DELETE FROM liste_attente WHERE idUser = "******" AND idOuvrage = " + idOuvrage; command.ExecuteNonQuery(); } } conn.Close(); return(ok); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { await PopulateClients(); returnUrl = returnUrl ?? Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var user = new Employee { UserName = Input.Email, Email = Input.Email, ClientId = Input.ClientId, FirstName = Input.FirstName, LastName = Input.LastName, Address = Input.Adress, ZIPCode = Input.ZIPCode, Residence = Input.Residence, PhoneNumber = Input.Phone, DateRegistered = DateTime.Now, Role = Input.Role, StartDateRole = DateTime.Now, OutOfService = false, EmailConfirmed = true }; var userModel = new EmployeeModel { FirstName = Input.FirstName, LastName = Input.LastName, Email = Input.Email, ClientId = Input.ClientId, Address = Input.Adress, ZIPCode = Input.ZIPCode, Residence = Input.Residence, Phone = Input.Phone, DateRegistered = DateTime.Now, Role = Input.Role, StartDateRole = DateTime.Now, OutOfService = false }; Mailservice.MailNewUser(userModel); var result = await _userManager.CreateAsync(user, (Input.FirstName + Input.LastName + "1!")); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = user.Id, code = code }, protocol: Request.Scheme); //await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", // $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); if (_userManager.Options.SignIn.RequireConfirmedAccount) { return(RedirectToPage("RegisterConfirmation", new { email = Input.Email })); } else { await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }