Beispiel #1
0
        public IActionResult Put(string id, [FromBody] Models.Borrower taskModel)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(NotFound());
            }

            var task = this.dbContext.Borrowers.SingleOrDefault(t => t.Id == id);

            if (task == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            task.Update(taskModel);
            this.dbContext.Update(task);
            this.dbContext.SaveChanges();

            return(Ok());
        }
        public async Task <IActionResult> Create([Bind("Id,Name,SSN,Date,Status,Crimeid,Score,Dob,Address")] Models.Borrower taskModel)
        {
            if (ModelState.IsValid)
            {
                this.dbContext.Add(taskModel);
                await this.dbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(taskModel));
        }
Beispiel #3
0
        public IActionResult Post([FromBody] Models.Borrower taskModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            this.dbContext.Add(taskModel);
            this.dbContext.SaveChanges();

            return(CreatedAtRoute("GetTask", new { id = taskModel.Id }, taskModel));
        }
        public async Task <IActionResult> Edit(string id, [Bind("Id,Name,SSN,Date,Status,Crimeid,Score,Dob,Address")] Models.Borrower taskModel)
        {
            if (id != taskModel.Id)
            {
                return(NotFound());
            }

            if (!this.dbContext.Borrowers.Any(t => t.Id == id))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                this.dbContext.Update(taskModel);
                await this.dbContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(taskModel));
        }
Beispiel #5
0
 public void Post([FromBody] Models.Borrower borrower)
 {
     _borrowerRepository.Insert(borrower);
     _borrowerRepository.Save();
 }