
Then I forced changes in visual studio using command in package manager console to update the new column and this command added the new column in the Набор данных Tblorders: < /p>
Код: Выделить всё
using System;
using System.Collections.Generic;
namespace BulletControls.Models;
public partial class TblOrder
{
public int Id { get; set; }
public string? Guid { get; set; }
public int? UserId { get; set; }
public int? ControlId { get; set; }
public string? PurchaseType { get; set; }
public int? PerDeveloper { get; set; }
public bool? IsResell { get; set; }
public decimal? TotalPrice { get; set; }
public DateOnly? Date { get; set; }
public bool? IsRegistered { get; set; }
public string? Email { get; set; }
public string? OrderId { get; set; }
public string? PaymentIntent { get; set; }
public virtual TblControl? Control { get; set; }
public virtual TblUser? User { get; set; }
}
Файл: < /p>
Код: Выделить всё
foreach (BulletControls.Controllers.ControlController.SessionBasketItem basketItem in basketItems)
{
decimal? totalPrice = 0;
totalPrice = basketItem.price * basketItem.perDevleper;
int percentPerDev = (basketItem.perDevleper - 1) * 2;
totalPrice = totalPrice - (totalPrice * ((decimal)percentPerDev / (decimal)100));
if (basketItem.isResell)
{
totalPrice = totalPrice + (totalPrice * ((decimal)35 / (decimal)100));
}
totalPrice = totalPrice + (totalPrice * ((decimal)20 / (decimal)100));
TblControl control = await ctx.TblControls.Where(x => x.Guid == basketItem.guid).FirstOrDefaultAsync();
TblOrder order = new TblOrder()
{
ControlId = control.Id,
Guid = orderGuid,
IsResell = basketItem.isResell,
PerDeveloper = basketItem.perDevleper,
PurchaseType = sessionBasket.type,
UserId = userId == null ? null : userId,
TotalPrice = totalPrice,
IsRegistered = userId == null ? false : true,
Email = email,
OrderId = orderGuid.Replace("-", "").ToUpper(),
PaymentIntent = paymentIntent.Id,
};
ctx.TblOrders.Add(order);
}
await ctx.SaveChangesAsync();
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... ual-studio
Мобильная версия