Ejemplo n.º 1
0
        public virtual ActionResult DraftEdit(ViewModels.Stage.Edit draftStageViewModel, string buttonClick = "")
        {
            if (buttonClick.Equals("Enregistrer"))
            {
                var stage = _stageRepository.GetById(draftStageViewModel.Id);
                var user  = _contactEnterpriseRepository.GetById(_httpContextService.GetUserId());
                if (stage == null)
                {
                    return(HttpNotFound());
                }
                if (stage.CompanyName != user.EnterpriseName)
                {
                    this.Flash(FlashMessageResources.NotAccessStage, FlashEnum.Error);
                    return(RedirectToAction(MVC.ContactEnterprise.DraftList()));
                }
                Mapper.Map(draftStageViewModel, stage);

                _stageRepository.Update(stage);

                return(RedirectToAction(MVC.ContactEnterprise.DraftList()));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(draftStageViewModel));
                }

                var stage = Mapper.Map <Stage>(draftStageViewModel);
                stage.PublicationDate = DateTime.Now.ToString();
                stage.Status          = StageStatus.New;

                _stageRepository.Update(stage);

                string message = String.Format(ContactEntrepriseToCoordinator.NewStageMessage, stage.CompanyName, stage.Id, stage.StageTitle);

                _notificationService.SendNotificationToAllCoordinator(ContactEntrepriseToCoordinator.NewStageTitle, message);
                this.Flash(FlashMessageResources.StageWaiting, FlashEnum.Info);
                return(RedirectToAction(MVC.ContactEnterprise.CreateStageSucceed()));
            }
        }
Ejemplo n.º 2
0
        public virtual ActionResult Edit(ViewModels.Stage.Edit editStageViewModel)
        {
            var stage = _stageRepository.GetById(editStageViewModel.Id);
            var user  = _contactEnterpriseRepository.GetById(_httpContextService.GetUserId());


            if (stage == null)
            {
                return(HttpNotFound());
            }

            if (stage.CompanyName != user.EnterpriseName)
            {
                this.Flash(FlashMessageResources.NotAccessStage, FlashEnum.Error);
                return(RedirectToAction(MVC.ContactEnterprise.ListStage()));
            }

            if (!ModelState.IsValid)
            {
                return(View(editStageViewModel));
            }

            Mapper.Map(editStageViewModel, stage);

            _stageRepository.Update(stage);

            string message = String.Format(ContactEntrepriseToCoordinator.EditStageMessage, stage.CompanyName, stage.Id, stage.StageTitle);

            _notificationService.SendNotificationToAllCoordinator(ContactEntrepriseToCoordinator.EditStageTitle,
                                                                  message);

            _notificationService.SendNotificationToAllStudent(ContactEnterpriseToStudent.EditStageTitle,
                                                              message);

            this.Flash(FlashMessageResources.EditSuccess, FlashEnum.Success);
            return(RedirectToAction(MVC.ContactEnterprise.ListStage()));
        }