Ignore:
Timestamp:
08/14/24 16:27:55 (3 months ago)
Author:
ElenaMoskova <elena.moskova99@…>
Branches:
main
Children:
ae6c071
Parents:
784b3ad
Message:

Update with triggers

Location:
PostgreSqlDotnetCore
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • PostgreSqlDotnetCore/Controllers/BlogController.cs

    r784b3ad r2639fab  
    6060        public ActionResult Create()
    6161        {
    62             var model = new BlogPostConsultation
    63             {
    64                 //date_askes = DateTime.Now // Поставете го датумот на моменталниот датум
    65                 // date_askes= DateTime.UtcNow.Date
    66                 date_askes = DateOnly.FromDateTime(DateTime.UtcNow.Date)
    67             };
     62            var model = new BlogPostConsultation();
    6863            return View(model);
    6964        }
     
    8378                    var user = await _userManager.GetUserAsync(User);
    8479                    var customerClass = db.CustomerObj.SingleOrDefault(x => x.email == user.Email);
    85                     // blogClass.date_askes = new DateTime();
    86                     // blogClass.date_askes = DateTime.UtcNow;
    87                     blogClass.date_askes = DateOnly.FromDateTime(DateTime.UtcNow);
    8880                    blogClass.users_id = customerClass.id;
    8981                    db.BlogPostControllerObj.Add(blogClass);
  • PostgreSqlDotnetCore/Controllers/ProductsController.cs

    r784b3ad r2639fab  
    22using Microsoft.AspNetCore.Mvc;
    33using Microsoft.EntityFrameworkCore;
     4using Npgsql;
     5using System.Linq;
    46using PostgreSqlDotnetCore.Models;
    5 using System.Net;
     7//using System.Net;
     8using System.Threading.Tasks;
     9using PostgreSqlDotnetCore.Data;
    610
    711namespace PostgreSqlDotnetCore.Controllers
     
    913    public class ProductsController : BaseController
    1014    {
     15
    1116        public ProductsController(UserManager<IdentityUser> userManager) : base(userManager)
    1217        {
     
    6873            var model = new ProductsClass
    6974            {
    70                 dateadded = DateTime.Now // Поставете го датумот на моменталниот датум
     75              //  dateadded = DateTime.Now // Поставете го датумот на моменталниот датум
    7176            };
    7277            return View(model);
    7378        }
     79
     80
     81
    7482
    7583        // POST: Customer/Create
     
    7886        [HttpPost]
    7987        [ValidateAntiForgeryToken]
    80         public ActionResult Create([Bind(include: "id,name,description,price, is_active, dateadded, category")] ProductsClass prodClass)
     88        public ActionResult Create([Bind(include: "id,name,description,price, is_active, dateadded, category, int available_quantity")] ProductsClass prodClass)
    8189        {
    8290            if (ModelState.IsValid)
    8391            {
    84                 prodClass.dateadded = new DateTime();
     92              //  prodClass.dateadded = new DateTime();
    8593                prodClass.isactive = true;
    8694                db.ProductObj.Add(prodClass);
     
    9199            return View(prodClass);
    92100        }
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
    93111
    94112        // GET: Customer/Edit/5
     
    117135        [HttpPost]
    118136        [ValidateAntiForgeryToken]
    119         public ActionResult Edit([Bind(include: "id,name,description,price, is_active, dateadded, category")] ProductsClass prodClass)
     137        public ActionResult Edit([Bind(include: "id,name,description,price, is_active, dateadded, category, int available_quantity")] ProductsClass prodClass)
    120138        {
    121139            if (ModelState.IsValid)
  • PostgreSqlDotnetCore/Data/ApplicationDbContext.cs

    r784b3ad r2639fab  
    5151            modelBuilder.Entity<BlogPostAnswers>().Metadata.SetIsTableExcludedFromMigrations(true);
    5252            //modelBuilder.Entity<PetCareAllData>().Metadata.SetIsTableExcludedFromMigrations(true);
     53           
     54
     55
    5356            base.OnModelCreating(modelBuilder);
    5457
     58            // Configure the relationship between VetCenter and CitiesClass
     59       
     60
     61           
    5562            // ... model definition ...
    5663        }
  • PostgreSqlDotnetCore/Models/ProductsClass.cs

    r784b3ad r2639fab  
    1919        public string price { get; set; }
    2020        public bool isactive { get; set; }
    21         public DateTime dateadded { get; set; }
     21        //public DateTime dateadded { get; set; }
     22
     23        public DateOnly dateadded { get; set; } = DateOnly.FromDateTime(DateTime.UtcNow);
    2224        public string category { get; set; }
    23        
     25
     26        public int  available_quantity { get; set; }
     27
    2428
    2529    }
  • PostgreSqlDotnetCore/Models/VetCenter.cs

    r784b3ad r2639fab  
    2424        public float longitude { get; set; }
    2525        public string phonenumber { get; set; }
     26       // [ForeignKey("CitiesClass")]
    2627        public int citiesid { get; set; }
     28       // public CitiesClass CitiesClass { get; set; }
    2729
    2830
  • PostgreSqlDotnetCore/Program.cs

    r784b3ad r2639fab  
    22using Microsoft.EntityFrameworkCore;
    33using PostgreSqlDotnetCore.Data;
     4using PostgreSqlDotnetCore.Models;
    45
    56var builder = WebApplication.CreateBuilder(args);
  • PostgreSqlDotnetCore/Views/Products/Create.cshtml

    r784b3ad r2639fab  
    4848        </div>
    4949    </div>
     50
     51        <div class="form-group">
     52            @Html.LabelFor(model => model.available_quantity, htmlAttributes: new { @class = "control-label col-md-2" })
     53            <div class="col-md-10">
     54                @Html.EditorFor(model => model.available_quantity, new { htmlAttributes = new { @class = "form-control" } })
     55                <span class="input-group-addon">euro</span>
     56                @Html.ValidationMessageFor(model => model.available_quantity, "", new { @class = "text-danger" })
     57            </div>
     58        </div>
     59   
    5060    @*<div class="form-group">
    5161            @Html.LabelFor(model => model.category, htmlAttributes: new { @class = "control-label col-md-2" })
     
    5767
    5868    <div class="form-group">
    59         <label for="category">Jobs:</label>
     69        <label for="category">Category:</label>
    6070        <select class="form-control" id="category" name="category">
    6171            <option value="">Select category</option>
  • PostgreSqlDotnetCore/Views/Products/Delete.cshtml

    r784b3ad r2639fab  
    5656        </dd>
    5757
     58        <dt>
     59            @Html.DisplayNameFor(model => model.available_quantity)
     60        </dt>
     61
     62        <dd>
     63            @Html.DisplayFor(model => model.available_quantity)
     64        </dd>
     65
    5866
    5967    </dl>
  • PostgreSqlDotnetCore/Views/Products/Details.cshtml

    r784b3ad r2639fab  
    5555        </dd>
    5656
     57        <dt>
     58            @Html.DisplayNameFor(model => model.available_quantity)
     59        </dt>
     60
     61        <dd>
     62            @Html.DisplayFor(model => model.available_quantity)
     63        </dd>
     64
    5765    </dl>
    5866</div>
  • PostgreSqlDotnetCore/Views/Products/Edit.cshtml

    r784b3ad r2639fab  
    5454        </div>
    5555    </div>
     56        <div class="form-group">
     57            @Html.LabelFor(model => model.available_quantity, htmlAttributes: new { @class = "control-label col-md-2" })
     58            <div class="col-md-10">
     59                @Html.EditorFor(model => model.available_quantity, new { htmlAttributes = new { @class = "form-control" } })
     60                @Html.ValidationMessageFor(model => model.available_quantity, "", new { @class = "text-danger" })
     61            </div>
     62        </div>
    5663
    5764    <div class="form-group">
Note: See TracChangeset for help on using the changeset viewer.