コード例 #1
0
        public virtual ActionResult Post(InstitutionalAgreementForm model)
        {
            if (model != null)
            {
                // do not process empty Guid
                if (model.EntityId == Guid.Empty)
                {
                    return(HttpNotFound());
                }

                if (model.RevisionId != 0)
                {
                    // find agreement
                    var agreement = _queryProcessor.Execute(
                        new GetMyInstitutionalAgreementByGuidQuery(User, model.EntityId));
                    if (agreement == null)
                    {
                        return(HttpNotFound());
                    }
                }
                else
                {
                    // find person's default affiliation
                    var person = _queryProcessor.Execute(new GetMyPersonQuery(User));
                    if (person == null || person.DefaultAffiliation == null)
                    {
                        return(HttpNotFound());
                    }
                }

                // always upload files
                UploadFiles(model);

                if (ModelState.IsValid)
                {
                    var command = new CreateOrUpdateInstitutionalAgreementCommand(User);
                    Mapper.Map(model, command);
                    _insertOrUpdateHandler.Handle(command);
                    SetFeedbackMessage(command.ChangeCount > 0
                        ? "Institutional agreement was saved successfully."
                        : "No changes were saved.");
                    return(RedirectToAction(MVC.InstitutionalAgreements.PublicSearch.Info(command.EntityId)));
                    //var hex = agreement.Files.ToList()[0].File.Content.ToHexString();
                }

                // set umbrella options
                model.Umbrella.Options = GetUmbrellaOptions(model.RevisionId);
                return(View(model));
            }
            return(HttpNotFound());
        }
コード例 #2
0
        public virtual ActionResult Post(InstitutionalAgreementForm model)
        {
            if (model != null)
            {
                // do not process empty Guid
                if (model.EntityId == Guid.Empty) return HttpNotFound();

                if (model.RevisionId != 0)
                {
                    // find agreement
                    var agreement = _queryProcessor.Execute(
                        new GetMyInstitutionalAgreementByGuidQuery(User, model.EntityId));
                    if (agreement == null) return HttpNotFound();
                }
                else
                {
                    // find person's default affiliation
                    var person = _queryProcessor.Execute(new GetMyPersonQuery(User));
                    if (person == null || person.DefaultAffiliation == null) return HttpNotFound();
                }

                // always upload files
                UploadFiles(model);

                if (ModelState.IsValid)
                {
                    var command = new CreateOrUpdateInstitutionalAgreementCommand(User);
                    Mapper.Map(model, command);
                    _commandHandler.Handle(command);
                    SetFeedbackMessage(command.ChangeCount > 0
                        ? "Institutional agreement was saved successfully."
                        : "No changes were saved.");
                    return RedirectToAction(MVC.InstitutionalAgreements.PublicSearch.Info(command.EntityId));
                    //var hex = agreement.Files.ToList()[0].File.Content.ToHexString();
                }

                // set umbrella options
                model.Umbrella.Options = GetUmbrellaOptions(model.RevisionId);
                return View(model);
            }
            return HttpNotFound();
        }
コード例 #3
0
 protected Guid Seed(CreateOrUpdateInstitutionalAgreementCommand command)
 {
     _agreementHandler.Handle(command);
     _unitOfWork.SaveChanges();
     return command.EntityId;
 }