public ActionResult Create(Guid id) { var model = new Models.SecondaryObject() { PrimaryObjectId = id, }; return(View(model)); }
public async Task <ActionResult> Edit(Guid id) { var secondaryObject = await _secondaryObjectService.GetAsync(id); var model = new Models.SecondaryObject() { Id = secondaryObject.Id, Description = secondaryObject.Description, Name = secondaryObject.Name, PrimaryObjectId = secondaryObject.PrimaryObject?.Id, }; return(View(model)); }
public async Task <ActionResult> Create(Guid id, FormCollection collection) { var model = new Models.SecondaryObject() { Description = collection[nameof(Models.SecondaryObject.Description)], Name = collection[nameof(Models.SecondaryObject.Name)], PrimaryObjectId = id, }; try { await _secondaryObjectService.CreateAsync(id, model); return(RedirectToAction("Edit", "PrimaryObjects", new { id = id })); } catch (Exception ex) { return(View(model)); } }
public async Task <ActionResult> Edit(Guid id, FormCollection collection) { var primaryObjectIdString = collection[nameof(Models.SecondaryObject.PrimaryObjectId)]; var model = new Models.SecondaryObject() { Id = id, Description = collection[nameof(Models.SecondaryObject.Description)], Name = collection[nameof(Models.SecondaryObject.Name)], PrimaryObjectId = string.IsNullOrWhiteSpace(primaryObjectIdString) ? null : Guid.Parse(primaryObjectIdString) as Guid?, }; try { await _secondaryObjectService.UpdateAsync(id, model); return(RedirectToAction("Edit", "PrimaryObjects", new { id = model.PrimaryObjectId })); } catch (Exception ex) { return(View(model)); } }