Esempio n. 1
0
        public ActionResult CreateVacancy(MyVacancy vacancy)
        {
            if (!ModelState.IsValid)
            {
                MessageForClient(ActionStatus.Error, $"Указанные данные не валидны.");
                return(RedirectToAction("Index", "Home"));
            }
            var savingVacancy = _mapper.Map <MyVacancy, VacancyBase>(vacancy);
            var identityUser  = _userRepository.FindUser(User.Identity.Name);

            if (identityUser.Status != ActionStatus.Success)
            {
                MessageForClient(ActionStatus.Error, $"Не удалось найти пользователя, которому требуется добавить объявление.");
                return(RedirectToAction("Index", "Home"));
            }
            savingVacancy.Creator    = identityUser.Entity.First() as UserBase;
            savingVacancy.LastEditor = savingVacancy.Creator;
            var updatedResult = _announcementRepository.CreateAnnouncement(savingVacancy);

            MessageForClient(updatedResult.Status, updatedResult.Message);
            if (updatedResult.Status != ActionStatus.Success)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("ShowUser", "User", new { (updatedResult.Entity.First() as VacancyBase).Creator.Login }));
        }
Esempio n. 2
0
        public ActionResult CreateCandidate(MyCandidate candidate, HttpPostedFileBase imageFile)
        {
            if (!ModelState.IsValid)
            {
                MessageForClient(ActionStatus.Error, $"Указанные данные не валидны.");
                return(RedirectToAction("Index", "Home"));
            }
            var savingCandidate = _mapper.Map <MyCandidate, CandidateBase>(candidate);
            var identityUser    = _userRepository.FindUser(User.Identity.Name);

            if (identityUser.Status != ActionStatus.Success)
            {
                MessageForClient(ActionStatus.Error, $"Не удалось найти пользователя, которому требуется добавить объявление.");
                return(RedirectToAction("Index", "Home"));
            }
            savingCandidate.Creator    = identityUser.Entity.First() as UserBase;
            savingCandidate.LastEditor = savingCandidate.Creator;
            if (imageFile != null)
            {
                byte[] buf = new byte[imageFile.ContentLength];
                imageFile.InputStream.Read(buf, 0, imageFile.ContentLength);
                savingCandidate.Photo = buf;
            }
            var updatedResult = _announcementRepository.CreateAnnouncement(savingCandidate);

            MessageForClient(updatedResult.Status, updatedResult.Message);
            if (updatedResult.Status != ActionStatus.Success)
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("ShowUser", "User", new { (updatedResult.Entity.First() as CandidateBase).Creator.Login }));
        }
Esempio n. 3
0
 public IActionResult Create(Announcement announcement)
 {
     if (ModelState.IsValid)
     {
         _repo.CreateAnnouncement(announcement);
         return(RedirectToAction("Index", "Announcement"));
     }
     return(View());
 }
Esempio n. 4
0
 public IActionResult Create(Announcement announcement)
 {
     if (ModelState.IsValid)
     {
         //create announcement and then reidrect back to the announcement index page
         _repo.CreateAnnouncement(announcement);
         return(RedirectToAction("Index", "Announcement"));
     }
     return(View());
 }
Esempio n. 5
0
        public async Task <IActionResult> AddAnnouncement(AnnouncementsList parentModel)
        {
            var model = parentModel.AnnouncementToAdd;

            if (!await _authHelpers.CheckDormitoryMembership(User, model.DormitoryId))
            {
                return(ControllerHelpers.ShowAccessDeniedErrorPage(this));
            }

            var announcement = new Announcement()
            {
                Message        = model.Message,
                DormitoryId    = model.DormitoryId,
                PublishingDate = DateTime.Now
            };

            _announcementRepo.CreateAnnouncement(announcement);

            return(RedirectToAction(nameof(Details), new { id = model.DormitoryId }));
        }