コード例 #1
0
ファイル: ClientController.cs プロジェクト: thofisch/Estime
        public ActionResult Edit(Guid? id, ClientInput input)
        {
            if( !ModelState.IsValid )
            {
                return View("Edit", input);
            }

            if( id.HasValue )
            {
                var client = Session.Get<Client>(id.Value);
                client.Name = input.Name;
            }
            else
            {
                var client = new Client
                {
                    Name = input.Name
                };

                var project = Project.CreateStandardProject(client);

                Session.Save(client);
                Session.Save(project);
            }

            return RedirectToAction("List");
        }
コード例 #2
0
ファイル: ClientController.cs プロジェクト: thofisch/Estime
        public ActionResult Edit(Guid id)
        {
            ViewBag.Title = "Rediger kunde";
            ViewBag.IsNew = false;

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

            ViewBag.Projects = client.Projects.Where(x => !x.StandardProject).ToList();

            var clientInput = new ClientInput
            {
                Id = client.Id,
                Name = client.Name,
            };

            return View(clientInput);
        }