Ejemplo n.º 1
0
 public static void MapOntoModel(this FieldViewModel viewModel, ref Field model)
 {
     model.Name = viewModel.Name;
     model.FieldType = viewModel.FieldType;
 }
Ejemplo n.º 2
0
        public ActionResult CreateField(ResourceViewModel viewModel)
        {
            //if (ModelState.IsValid)
            //{
            var resource = _resourceRepository.GetById(viewModel.Id);
            var field = new Field()
                            {
                                Resource = resource,
                                Name = viewModel.NewField.Name,
                                FieldType = viewModel.NewField.FieldType
                            };

            field.FieldDocs.Add(new FieldDoc()
                                    {
                                        Language = Configuration.DefaultLanguage,
                                        Description = viewModel.NewField.Description,
                                        Field = field
                                    });

            resource.Fields.Add(field);

            _resourceRepository.Save(resource);
            _resourceRepository.SaveChanges();

            return RedirectToAction("Edit", new { id = viewModel.Id });
            //}
            //else
            //{
            //    return View("Edit", viewModel);
            //}

        }