Beispiel #1
0
        public virtual ActionResult InviteCompanies(InviteCompanies inviteCompaniesVm)
        {
            var coordinator = _coordinatorRepository.GetById(_httpContextService.GetUserId());

            var employees = _employeeRepository.GetAll().ToList();

            if (!ModelState.IsValid)
            {
                return(View(MVC.InviteCompanies.Views.ViewNames.InviteCompanies));
            }

            foreach (var employee in employees)
            {
                try
                {
                    var mail = _emailService.BuildMail(employee.Identifier, coordinator.Identifier,
                                                       inviteCompaniesVm.Subject, inviteCompaniesVm.Body);
                    _emailService.SendEmail(mail);
                }
                catch (Exception)
                {
                    var errorMessage = WebMessage.InviteCompaniesMessage.GENERIC_INVITE_COMPANIES_ERROR;
                    return(View(MVC.InviteCompanies.Views.ViewNames.InviteCompanies).Error(errorMessage));
                }
            }

            return(RedirectToAction(MVC.Coordinator.Views.ViewNames.Index, MVC.Coordinator.Name).Success(WebMessage.InviteCompaniesMessage.INVITE_COMPANIES_SUCCES));
        }
Beispiel #2
0
        public virtual ActionResult Details(ViewModels.InternshipOffer.FullOffer offerVm)
        {
            Coordinator     coordinator;
            InternshipOffer internshipOffer;

            try
            {
                internshipOffer = _internshipOfferRepository.GetById(offerVm.Id);
                offerVm.Title   = internshipOffer.Title;
                coordinator     = _coordinatorRepository.GetById(_httpContextService.GetUserId());
            }
            catch (Exception)
            {
                return(HttpNotFound());
            }

            try
            {
                var mail = _emailService.BuildMail(internshipOffer.Contact.Email, coordinator.Identifier,
                                                   WebMessage.InternshipOfferMessage.DENY_OFFER_MAIL_SUBJECT, BuildDenyMailBody(offerVm));
                UpdateInternshipOfferToRefusedStatus(internshipOffer);
                _notificationService.CompanyNotification(internshipOffer.Company, WebMessage.NotificationMessage.ONE_OF_YOUR_OFFER_HAS_BEEN_PUBLICATED_HAS_BEEN_DENIED, "InternshipOffer", "EmployeeIndex");
                _emailService.SendEmail(mail);
            }
            catch (Exception e)
            {
                ModelState.AddModelError("Body", WebMessage.InternshipOfferMessage.GENERIC_DENY_ERROR);
            }

            if (!ModelState.IsValid)
            {
                return(View(MVC.InternshipOffer.Views.ViewNames.Details, internshipOffer));
            }

            const string feedbackMessage = WebMessage.InternshipOfferMessage.OFFER_DENIED_SUCCESS;

            return(RedirectToAction(MVC.InternshipOffer.CoordinatorIndex().Success(feedbackMessage)));
        }