Ignore:
Timestamp:
08/20/24 15:04:19 (6 weeks ago)
Author:
ElenaMoskova <elena.moskova99@…>
Branches:
main
Children:
6782104
Parents:
ae6c071
Message:

fix bugs and new pages

Fix BlogPostAnswers
fix present data in the lists

Location:
PostgreSqlDotnetCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • PostgreSqlDotnetCore/Controllers/BlogController.cs

    rae6c071 r8f8226c  
    4444            // query
    4545            var query = from st in db.BlogPostAnswersObj
    46                         where st.blogpostconsultationid == blogClass.id
     46                        where st.BlogPostConsultationid == blogClass.id
    4747                        select st;
    4848            //elenaaa
  • PostgreSqlDotnetCore/Controllers/PetCaresController.cs

    rae6c071 r8f8226c  
    130130
    131131        // GET: Customer/Edit/5
    132         public ActionResult Edit(int? id)
     132        /*  public ActionResult Edit(int? id)
     133          {
     134              if (id == null)
     135              {
     136                  return RedirectToAction("NotExist", "Error");
     137              }
     138              Pet_CaresClass peClass = db.PetCaresObj.Find(id);
     139              if (peClass == null)
     140              {
     141                  return RedirectToAction("NotExist", "Error");
     142              }
     143
     144
     145              return View(peClass);
     146          }*/
     147        // GET: Customer/Edit/5
     148        /* public  ActionResult Edit(int? id)
     149         {
     150             if (id == null)
     151             {
     152                 return RedirectToAction("NotExist", "Error");
     153             }
     154             Pet_CaresClass peClass = db.PetCaresObj.Find(id);
     155             if (peClass == null)
     156             {
     157                 return RedirectToAction("NotExist", "Error");
     158             }
     159
     160
     161             return View(peClass);
     162         }*/
     163        public async Task<ActionResult> Edit(int? id)
    133164        {
    134165            if (id == null)
     
    136167                return RedirectToAction("NotExist", "Error");
    137168            }
    138             Pet_CaresClass peClass = db.PetCaresObj.Find(id);
     169
     170            Pet_CaresClass peClass = await db.PetCaresObj.FindAsync(id);
    139171            if (peClass == null)
    140172            {
    141173                return RedirectToAction("NotExist", "Error");
    142174            }
    143             return View(peClass);
    144         }
     175
     176            var vetCenters = await db.VetCentersObj.ToListAsync();
     177            ViewBag.VetCenters = new SelectList(vetCenters, "id", "name", peClass.vetcentersid);
     178
     179            return View(peClass);
     180        }
     181
     182
    145183
    146184        // POST: Customer/Edit/5
     
    149187        [HttpPost]
    150188        [ValidateAntiForgeryToken]
    151         public async Task<ActionResult> EditAsync([Bind(include: "id,title,description,dateending, start_date vetcentersid")] Pet_CaresClass peClass)
     189        public async Task<ActionResult> EditAsync([Bind(include: "id,title,description,dateending, vetcentersid")] Pet_CaresClass peClass)
    152190        {
    153191            bool isAuthenticated = User.Identity.IsAuthenticated;
     
    156194                return RedirectToAction("AccessDenied", "Error");
    157195            }
    158              
     196
    159197            if (ModelState.IsValid)
    160198            {
    161199                peClass.dateending = DateTime.SpecifyKind(peClass.dateending, DateTimeKind.Utc);
    162                 peClass.start_date = DateTime.SpecifyKind(peClass.start_date, DateTimeKind.Utc);
    163200                var user = await _userManager.GetUserAsync(User);
    164201                var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
     
    171208        }
    172209
     210
     211
     212
    173213        // GET: Customer/Delete/5
    174214        public ActionResult Delete(int? id)
  • PostgreSqlDotnetCore/Controllers/PetsController.cs

    rae6c071 r8f8226c  
    7373        [HttpPost]
    7474        [ValidateAntiForgeryToken]
    75         public async Task<ActionResult> CreateAsync([Bind(include: "id,color,description,dateofbirthday, usersid,typeofpetsid")] PetsClass peClass)
     75        public async Task<ActionResult> CreateAsync([Bind(include: "id,name,color,description,dateofbirthday, usersid,typeofpetsid")] PetsClass peClass)
    7676        {
    7777            bool isAuthenticated = User.Identity.IsAuthenticated;
     
    116116        [HttpPost]
    117117        [ValidateAntiForgeryToken]
    118         public async Task<ActionResult> EditAsync([Bind(include: "id,color,description,dateofbirthday, usersid,typeofpetsid")] PetsClass peClass)
     118        public async Task<ActionResult> EditAsync([Bind(include: "id,name, color,description,dateofbirthday, usersid,typeofpetsid")] PetsClass peClass)
    119119        {
    120120            bool isAuthenticated = User.Identity.IsAuthenticated;
  • PostgreSqlDotnetCore/Models/BlogPostAnswers.cs

    rae6c071 r8f8226c  
    1212        public int parent_id { get; set; }
    1313        public string reply { get; set; }
    14         public int? blogpostconsultationid { get; set; }
     14
     15        [ForeignKey("BlogPostConsultation")]
     16        [Column("blogpostconsid")]
     17        public int BlogPostConsultationid { get; set; }
     18        public BlogPostConsultation BlogPostConsultation { get; set; }
     19
    1520        public int usersid { get; set; }
    1621    }
  • PostgreSqlDotnetCore/Models/PetsClass.cs

    rae6c071 r8f8226c  
    1616        public string color { get; set; }
    1717
     18        public string name { get; set; }
     19
    1820        public string description { get; set; }
    1921       // public DateTime dateofbirthday { get; set; }
  • PostgreSqlDotnetCore/Views/PetCares/Edit.cshtml

    rae6c071 r8f8226c  
    4848        </div>
    4949
    50     <div class="form-group">
     50        <div class="form-group">
     51            @Html.LabelFor(model => model.vetcentersid, htmlAttributes: new { @class = "control-label col-md-2" })
     52            <div class="col-md-10">
     53                @Html.DropDownListFor(model => model.vetcentersid, (SelectList)ViewBag.VetCenters, "Select VetCenter", new { @class = "form-control" })
     54                @Html.ValidationMessageFor(model => model.vetcentersid, "", new { @class = "text-danger" })
     55            </div>
     56        </div>
     57
     58
     59   @*<div class="form-group">
    5160        @Html.LabelFor(model => model.vetcentersid, htmlAttributes: new { @class = "control-label col-md-2" })
    5261        <div class="col-md-10">
     
    5564        </div>
    5665    </div>
     66    *@
     67        @*
     68        <div class="form-group">
     69            <label class="control-label col-md-2" for="vetcentersid">VetCenter:</label>
     70            <div class="col-md-10">
     71                @Html.DropDownList("vetcentersid", (SelectList)ViewBag.VetCenters, "Select VetCenter", new { @class = "form-control" })
     72            </div>
     73        </div>
     74    *@
    5775
    5876
  • PostgreSqlDotnetCore/Views/Pets/Create.cshtml

    rae6c071 r8f8226c  
    1616    <hr />
    1717    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
     18
     19        <div class="form-group">
     20            @Html.LabelFor(model => model.name, htmlAttributes: new { @class = "control-label col-md-2" })
     21            <div class="col-md-10">
     22                @Html.EditorFor(model => model.name, new { htmlAttributes = new { @class = "form-control" } })
     23                @Html.ValidationMessageFor(model => model.name, "", new { @class = "text-danger" })
     24            </div>
     25        </div>
    1826
    1927    <div class="form-group">
  • PostgreSqlDotnetCore/Views/Pets/Delete.cshtml

    rae6c071 r8f8226c  
    1212    <hr />
    1313    <dl class="dl-horizontal">
     14
     15        <dt>
     16            @Html.DisplayNameFor(model => model.name)
     17        </dt>
     18
     19        <dd>
     20            @Html.DisplayFor(model => model.name)
     21        </dd>
    1422        <dt>
    1523            @Html.DisplayNameFor(model => model.color)
  • PostgreSqlDotnetCore/Views/Pets/Details.cshtml

    rae6c071 r8f8226c  
    1111    <hr />
    1212    <dl class="dl-horizontal">
     13        <dt>
     14            @Html.DisplayNameFor(model => model.name)
     15        </dt>
     16
     17        <dd>
     18            @Html.DisplayFor(model => model.name)
     19        </dd>
    1320        <dt>
    1421            @Html.DisplayNameFor(model => model.color)
  • PostgreSqlDotnetCore/Views/Pets/Edit.cshtml

    rae6c071 r8f8226c  
    1818    @Html.HiddenFor(model => model.id)
    1919
     20        <div class="form-group">
     21            @Html.LabelFor(model => model.name, htmlAttributes: new { @class = "control-label col-md-2" })
     22            <div class="col-md-10">
     23                @Html.EditorFor(model => model.name, new { htmlAttributes = new { @class = "form-control" } })
     24                @Html.ValidationMessageFor(model => model.name, "", new { @class = "text-danger" })
     25            </div>
     26        </div>
    2027    <div class="form-group">
    2128        @Html.LabelFor(model => model.color, htmlAttributes: new { @class = "control-label col-md-2" })
  • PostgreSqlDotnetCore/Views/Pets/Index.cshtml

    rae6c071 r8f8226c  
    1212<table class="table">
    1313    <tr>
     14        <th>
     15            @Html.DisplayNameFor(model => model.name)
     16        </th>
    1417
    1518        <th>
     
    3639@foreach (var item in Model) {
    3740    <tr>
     41            <td>
     42                @Html.DisplayFor(modelItem => item.name)
     43            </td>
    3844        <td>
    3945            @Html.DisplayFor(modelItem => item.color)
Note: See TracChangeset for help on using the changeset viewer.