예제 #1
0
        public ActionResult New(Guid clientId)
        {
            ViewBag.Title = "Opret nyt project";

            var model = new ProjectInput
            {
                ClientId = clientId
            };
            return View("Edit", model);
        }
예제 #2
0
        public ActionResult Edit(Guid id)
        {
            ViewBag.Title = "Rediger projekt";

            var project = Session
                .QueryOver<Project>()
                .Where(x => x.Id==id)
                .Fetch(x => x.Client).Eager
                .SingleOrDefault();

            var clientInput = new ProjectInput
            {
                Id = project.Id,
                ClientId = project.Client.Id,
                Name = project.Name
            };

            return View(clientInput);
        }
예제 #3
0
        public ActionResult Edit(Guid id, ProjectInput input)
        {
            if( !ModelState.IsValid )
            {
                return View("Edit", input);
            }

            var client = Session.Get<Client>(input.ClientId);

            if( id!=Guid.Empty )
            {
                var project = Session.Get<Project>(id);
                project.ChangeName(input.Name);
            }
            else
            {
                var project = Project.CreateProject(client, input.Name);

                Session.Save(project);
            }

            return RedirectToAction("Edit", "Client", new {id = client.Id});
        }