public async Task <IActionResult> Create([Bind("DateAssigned,NameOrGroup,NameOrGroupNumber")] ResponsibleParty responsibleParty) { ModelState.Remove("UserId"); ModelState.Remove("User"); if (ModelState.IsValid) { var currentUser = await GetCurrentUserAsync(); responsibleParty.UserId = currentUser.Id; _context.Add(responsibleParty); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", responsibleParty.UserId); return(View(responsibleParty)); }
public static XElement MakeResponsiblePartyNode(ResponsibleParty c) { if (c == null || c.Name.IsBlank()) { return(null); } return(new XElement(gmd + "CI_ResponsibleParty", new XElement(gmd + "organisationName", new XElement(gco + "CharacterString", c.Name)), new XElement(gmd + "contactInfo", new XElement(gmd + "CI_Contact", new XElement(gmd + "address", new XElement(gmd + "CI_Address", new XElement(gmd + "electronicMailAddress", new XElement(gco + "CharacterString", c.Email)))))), new XElement(gmd + "role", new XElement(gmd + "CI_RoleCode", new XAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#CI_RoleCode"), new XAttribute("codeListValue", c.Role), c.Role)))); // todo should ideally store the human-readable meaning as the element value, but for now using the codeListValue }
public async Task <IActionResult> Edit(int id, [Bind("ResponsiblePartyId,UserId,NameOrGroup,NameOrGroupNumber,UserId")] ResponsibleParty responsibleParty) { var currentUser = await GetCurrentUserAsync(); if (id != responsibleParty.ResponsiblePartyId) { return(NotFound()); } ModelState.Remove("User"); ModelState.Remove("DateAssigned"); ModelState.Remove("UserId"); responsibleParty.UserId = currentUser.Id; if (ModelState.IsValid) { try { _context.Update(responsibleParty); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentTypeExists(responsibleParty.ResponsiblePartyId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", responsibleParty.UserId); return(View(responsibleParty)); }
public ResponsiblePartyDeleteViewModel(ResponsibleParty responsibleParty) { ResponsibleParty = responsibleParty; }