public async Task <ActionResult> Add(PersonViewModel personViewModel, int?groupId = null) { if (ModelState.IsValid) { await personManager.AddAsync(personViewModel.ToEntity()); return(RedirectToAction("Index", new { groupId = groupId })); } personViewModel.GroupList = FillGroupList(groupId); return(View(personViewModel)); }
public async Task <int> Register(Customer customer) { // 1. Save Person into Face API and into our DB var person = customer.ToPerson(); person.GroupId = int.Parse(ConfigurationManager.AppSettings["DefaultGroupID"]); await personManager.AddAsync(person); // 2. Save Person's Picture into Face API and into our DB var face = customer.ToFace(); face.PersonId = person.Id; await faceManager.AddAsync(face); // 3. Return User ID return(person.Id); }
public async Task <ActionResult> Add(PersonViewModel personViewModel, int?groupId = null) { try { if (ModelState.IsValid) { await personManager.AddAsync(personViewModel.ToEntity()); return(RedirectToAction("Index", new { groupId = groupId })); } personViewModel.GroupList = FillGroupList(groupId); return(View(personViewModel)); } catch (BusinessException ex) { ModelState.AddModelError(string.Empty, ex.Message); personViewModel.GroupList = FillGroupList(groupId); return(View(personViewModel)); } }
public IActionResult Add([FromBody] Person person) { return(new WebApiPost(this, () => _manager.AddAsync(person), operationType: OperationType.Unspecified, statusCode: HttpStatusCode.Created)); }