Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Surname,Middlename")] Person person)
        {
            if (id != person.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _queryable.SendSqlQueryAsync(
                        "update_person",
                        new []
                    {
                        new KeyValuePair <string, object>("p_id", person.Id),
                        new KeyValuePair <string, object>("p_name", person.Name),
                        new KeyValuePair <string, object>("p_surname", person.Surname),
                        new KeyValuePair <string, object>("p_middlename", person.Middlename)
                    },
                        System.Data.CommandType.StoredProcedure
                        );
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonExists(person.Id))
                    {
                        return(NotFound());
                    }
                    throw;
                }
                return(RedirectToAction("Index"));
            }
            return(View(person));
        }