Example #1
0
        // GET: Compare/Edit/5
        public async Task <IActionResult> Edit(int id, string accountNo, string withdrawalDate)
        {
            try
            {
                AccountB receivedAccountB = new AccountB();
                receivedAccountB.Id             = id;
                receivedAccountB.AccountNo      = accountNo;
                receivedAccountB.WithdrawalDate = withdrawalDate;

                using (var httpClient = new HttpClient())
                {
                    var content = JsonConvert.SerializeObject(receivedAccountB);

                    var request = new StringContent(content, Encoding.UTF8, "application/json");

                    await httpClient.PutAsync("https://localhost:44345/api/AccountBsAPI/" + id, request);
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccountBExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,AccountNo,WithdrawalDate")] AccountB accountB)
        {
            if (id != accountB.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accountB);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountBExists(accountB.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountB));
        }
Example #3
0
        public async Task <IActionResult> PutAccountB([FromRoute] int id, [FromBody] AccountB accountB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != accountB.Id)
            {
                return(BadRequest());
            }

            _context.Entry(accountB).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccountBExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("Id,AccountNo,WithdrawalDate")] AccountB accountB)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accountB);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountB));
        }
Example #5
0
        public async Task <IActionResult> PostAccountB([FromBody] AccountB accountB)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.AccountB.Add(accountB);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAccountB", new { id = accountB.Id }, accountB));
        }