public ActionResult Edit(EmployeeViewModel model)
        {
            model.Employee.Gender            = _repository.GetOptionById <Gender, DenormalizedReference>(model.Employee.Gender.DenormalizedId);
            model.Employee.ProgrammingRating = _repository.GetOptionById <ProgrammingRating, DenormalizedReference>(model.Employee.ProgrammingRating.DenormalizedId);

            model.Employee.Skills = model.LstSkill.Where(c => c.IsSelected == true).Select(c => c.DenormalizedReference).ToList();

            _repository.Update <Employee>(model.Employee);

            return(RedirectToAction("Index"));
        }
예제 #2
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));
            }
        }
        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 }));
        }