Exemplo n.º 1
0
        public ActionResult Edit(ClientViewModel model)
        {
            if (ModelState.IsValid)
            {//this one is a bit different because we have embedded Contacts that are not posted back from the same form.
                _repository.Update(model.Client);

                return RedirectToAction("Edit", new { id = model.Client.Id });
            }
            else
            {
                return View(model.Client.Id);
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(ClientViewModel model)
        {
            if (ModelState.IsValid)
            {
                _repository.Insert<Client>(model.Client);

                return RedirectToAction("Index");
            }
            else
            {
                return View();
            }
        }
Exemplo n.º 3
0
        public ActionResult Edit(string id)
        {
            MXTimer timing = new MXTimer();

            ClientViewModel model = new ClientViewModel
            {
                Client = _repository.GetOne<Client>(id),
            };

            ViewBag.QueryTime = timing.Finish();

            return View(model);
        }
Exemplo n.º 4
0
        public ActionResult Create(ClientViewModel model)
        {
            Client client = _repository.GetOne<Client>(model.Client.Id);

            if (client.Contacts == null)
            {
                client.Contacts = new List<Contact>();
            }

            model.Client.Contacts[0].Id = MXMongoIdGenerator.NewId;

            client.Contacts.Add(model.Client.Contacts[0]);

            _repository.Update<Client>(client);

            return RedirectToAction("Index", new { id = model.Client.Id });
        }