ASP.NET Core MVC (N Tiered Architecture) Insert Problem [SOLVED]

67 Views Asked by At

I am developing an ASP.NET Core MVC project using PostgreSQL db with N-tiered architecture.

In my project, I can pull data from a table but I can't insert it and it doesn't give any error. When I tried with AJAX, I couldn't see any error in LOG.

Can you help me?

Thanks,

Controller side code:

    [HttpGet]
    public IActionResult AddTask()
    {
        return View();
    }

    [HttpPost]
    public IActionResult AddTask(TaskList taskList)
    {
        taskList.CreateDate = DateTime.Now;
        taskList.FinishDate = DateTime.Now;
        taskList.CreateUser = 1;
        taskList.Status = false;
        //taskList.Priority = 1;
        taskListManager.itemAdd(taskList);
        return RedirectToAction("Home/Index");
    }

The view looks like this:

@using EntityLayer.Concrete;

@model List<TaskList>

<form method="post">
    <div class="card">
        <div class="card-body">
            <div style="text-align:right">
                <button class="btn btn-primary" id="btnNewTask" type="button">Yeni Görev Oluştur</button>
            </div>

            <div class="card-body p-4">
                <h5 class="card-title fw-semibold mb-4">Bekleyen İşlerim</h5>
                <div class="table-responsive">
                    <table class="table text-nowrap mb-0 align-middle">
                        <thead class="text-dark fs-4">
                            <tr>
                                <th class="border-bottom-0">
                                    <h6 class="fw-semibold mb-0">Oluşturan Kullanıcı</h6>
                                </th>
                                <th class="border-bottom-0">
                                    <h6 class="fw-semibold mb-0">Konu Başlığı</h6>
                                </th>
                                <th class="border-bottom-0">
                                    <h6 class="fw-semibold mb-0">Öncelik</h6>
                                </th>
                                <th class="border-bottom-0">
                                    <h6 class="fw-semibold mb-0">Oluşturma Tarihi</h6>
                                </th>
                                <th class="border-bottom-0">
                                    <h6 class="fw-semibold mb-0">Durum</h6>
                                </th>
                                <th class="border-bottom-0">
                                    <h6 class="fw-semibold mb-0">Detay</h6>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model)
                            {
                                <tr>
                                    <td class="border-bottom-0">
                                        <h6 class="fw-semibold mb-1">@item.CreateUser</h6>
                                        <span class="fw-normal">Kendim</span>
                                    </td>
                                    <td class="border-bottom-0">
                                        <p class="fw-semibold mb-1l">@item.TaskTitle</p>
                                    </td>
                                    <td class="border-bottom-0">
                                        <div class="d-flex align-items-center gap-2">
                                            @if (item.Priority == 1)
                                            {
                                                <span class="badge bg-secondary rounded-3 fw-semibold">Düşük</span>
                                            }
                                            @if (item.Priority == 2)
                                            {
                                                <span class="badge bg-success rounded-3 fw-semibold">Normal</span>
                                            }
                                            @if (item.Priority == 3)
                                            {
                                                <span class="badge bg-danger rounded-3 fw-semibold">Yüksek</span>
                                            }
                                        </div>
                                    </td>
                                    <td class="border-bottom-0">
                                        <h6 class="mb-0 fw-normal">@item.CreateDate</h6>
                                    </td>
                                    <td class="border-bottom-0">
                                        @if (item.Status == false)
                                        {
                                            <span class="badge bg-warning rounded-3 fw-semibold">Bekleniyor</span>
                                        }
                                        @if (item.Status == true)
                                        {
                                            <span class="badge bg-dark rounded-3 fw-semibold">Tamamlandı</span>
                                        }
                                    </td>
                                    <td class="border-bottom-0">
                                        <button class="btn btn-light m-1" id="btnDetay" type="button" href="#">Detaya Git</button>
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="modal" id="myModal">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">Yeni İş Oluştur</h4>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <label class="form-label">Konu Başlığı</label>
                    <input class="form-control" id="txtAddTaskTitle" name="TaskTitle" placeholder="Konu Başlığı Giriniz" />
                    <br />
                    <label class="form-label">Açıklama</label>
                    <input class="form-control" id="txtAddTaskDetails" name="TaskDetails" placeholder="Konu İle İlgili Açıklama Giriniz" />
                    <br />
                    <label class="form-label">Öncelik</label>
                    <select class="form-control" name="Priority" id="ddlPriority">
                        <option value="0">Lütfen Öncelik Durumunu Seçiniz</option>
                        <option value="1" class="badge bg-secondary rounded-3 fw-semibold">Düşük</option>
                        <option value="2" class="badge bg-success rounded-3 fw-semibold">Normal</option>
                        <option value="3" class="badge bg-danger rounded-3 fw-semibold">Yüksek</option>
                    </select>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary m-1" id="btnAddTask">Ekle</button>
                </div>
            </div>
        </div>
    </div>
</form>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

I did not encounter any errors.

0

There are 0 best solutions below