Esempio n. 1
0
        public ActionResult Update(ProposalBindingModel form)
        {
            var field = _uow.Categories.FindById(form.FieldId);
            var hosting = _uow.Organizations.FindById(form.HostingId);
            // in 01-1 relation, the key is the same for the dependence property, application.id=proposal.id
            var proposal = _uow.Proposals.FindById(form.Id);
            if (ModelState.IsValid)
            {
                proposal.Title = form.Title;
                proposal.Field = field ?? proposal.Field;
                proposal.Hosting = hosting;
                proposal.Abstract = form.Abstract;

                _uow.Save();
            }

            return RedirectToAction<ProposalController>(c => c.Update(proposal.Id));
        }
Esempio n. 2
0
        public ActionResult NewProposal(Guid applicationId, ProposalBindingModel form)
        {
            var app = _uow.Apps.AllIncluding(a => a.Proposal).FirstOrDefault(a => a.Id == applicationId);

            var cat = _uow.Categories.FindById(form.FieldId);
            var org = _uow.Organizations.FindById(form.HostingId);
            if (app.Proposal == null)
                app.Proposal = Proposal.New(form.Title, form.Abstract, form.StartDate, form.FinishDate, form.Duration, form.TotalBudget, form.RequetBudget, form.Content);
            else
                UpdateProposal(app.Proposal, form);

            app.Proposal.Kind = form.Kind;
            app.Proposal.Field = cat;
            app.Proposal.Hosting = org;

            _uow.Save();

            return RedirectToAction<ApplicationController>(c => c.Details(app.Id));
        }
Esempio n. 3
0
 public void UpdateProposal(Proposal toUpdate, ProposalBindingModel form)
 {
     toUpdate.Title = form.Title;
     toUpdate.Abstract = form.Abstract;
     toUpdate.Content = form.Content;
 }
Esempio n. 4
0
        public ActionResult NewProposal(Guid applicationId)
        {
            var app = _uow.Apps.AllIncluding(a => a.Proposal, a => a.Proposal.Field, a => a.Opportunity.Grant.Classification).FirstOrDefault(a => a.Id == applicationId);

            var vm = new ProposalBindingModel()
            {
                StartDate = DateTime.Today,
                FinishDate = DateTime.Today
            };
            if (app.Proposal != null)
                vm = AutoMapper.Mapper.Map<ProposalBindingModel>(app.Proposal);

            ViewData["Hostings"] = _uow.Organizations.All
                                        .ToSelectList(c => c.Id.ToString(), c => c.Name.ToString(), string.Empty);

            var categories = _uow.Categories.AllIncluding(c => c.Parent).Where(c => c.Parent == null)
            .Project().To<CategoryViewModel>().ToList();

            categories.ForEach(n => BuildChildNode(n));
            var list = new List<SelectListItem>();
            foreach (var item in categories)
            {
                list.Add(new SelectListItem
                {
                    Value = item.Id.ToString(),
                    Text = item.Name,
                    Selected = app.Proposal == null ? false : item.Id == app.Proposal.Field.Id
                });
                ToSelectList(item, list, app.Proposal);
            }

            ViewData["Categories"] = list;

            return View("_Proposal", vm);
        }