...
This commit is contained in:
@@ -256,13 +256,39 @@ namespace Back.Controllers
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID,
|
||||
setm = Invoice.setm,
|
||||
cui = Invoice.cui,
|
||||
crn = Invoice.crn,
|
||||
CottageDateOfCustomsDeclaration = Invoice.CottageDateOfCustomsDeclaration,
|
||||
ft = Invoice.ft,
|
||||
cdcn = Invoice.cdcn,
|
||||
insp = Invoice.insp,
|
||||
billid = Invoice.billid,
|
||||
pspd = Invoice.pspd,
|
||||
scc = Invoice.scc,
|
||||
scln = Invoice.scln,
|
||||
seventeentax = Invoice.seventeentax,
|
||||
tinc = Invoice.tinc,
|
||||
invoiceDetails = Invoice.invoiceDetails.Select(s => new InvoiceItem
|
||||
{
|
||||
CODID = s.CODID,
|
||||
am = s.am,
|
||||
fee = s.fee,
|
||||
dis = s.dis,
|
||||
|
||||
bros = s.bros,
|
||||
bsrn = s.bsrn,
|
||||
consfee = s.consfee,
|
||||
cut = s.cut,
|
||||
exr = s.exr,
|
||||
nw = s.nw,
|
||||
odam = s.odam,
|
||||
odr = s.odr,
|
||||
odt = s.odt,
|
||||
olam = s.olam,
|
||||
olr = s.olr,
|
||||
olt = s.olt,
|
||||
spro = s.spro,
|
||||
sscv = s.sscv,
|
||||
ssrv = s.ssrv
|
||||
}).ToList()
|
||||
}, false);
|
||||
if (result > 0)
|
||||
@@ -285,13 +311,39 @@ namespace Back.Controllers
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID,
|
||||
setm = Invoice.setm,
|
||||
cui = Invoice.cui,
|
||||
crn = Invoice.crn,
|
||||
CottageDateOfCustomsDeclaration = Invoice.CottageDateOfCustomsDeclaration,
|
||||
ft = Invoice.ft,
|
||||
cdcn = Invoice.cdcn,
|
||||
insp = Invoice.insp,
|
||||
billid = Invoice.billid,
|
||||
pspd = Invoice.pspd,
|
||||
scc = Invoice.scc,
|
||||
scln = Invoice.scln,
|
||||
seventeentax = Invoice.seventeentax,
|
||||
tinc = Invoice.tinc,
|
||||
invoiceDetails = Invoice.invoiceDetails.Select(s => new InvoiceItem
|
||||
{
|
||||
CODID = s.CODID,
|
||||
am = s.am,
|
||||
fee = s.fee,
|
||||
dis = s.dis,
|
||||
|
||||
bros = s.bros,
|
||||
bsrn = s.bsrn,
|
||||
consfee = s.consfee,
|
||||
cut = s.cut,
|
||||
exr = s.exr,
|
||||
nw = s.nw,
|
||||
odam = s.odam,
|
||||
odr = s.odr,
|
||||
odt = s.odt,
|
||||
olam = s.olam,
|
||||
olr = s.olr,
|
||||
olt = s.olt,
|
||||
spro = s.spro,
|
||||
sscv = s.sscv,
|
||||
ssrv = s.ssrv
|
||||
}).ToList()
|
||||
}, false);
|
||||
if (result1 > 0)
|
||||
@@ -326,13 +378,39 @@ namespace Back.Controllers
|
||||
IsDeleted = false,
|
||||
PatternID = Invoice.PatternID,
|
||||
setm = Invoice.setm,
|
||||
cui = Invoice.cui,
|
||||
crn = Invoice.crn,
|
||||
CottageDateOfCustomsDeclaration = Invoice.CottageDateOfCustomsDeclaration,
|
||||
ft = Invoice.ft,
|
||||
cdcn = Invoice.cdcn,
|
||||
insp = Invoice.insp,
|
||||
billid = Invoice.billid,
|
||||
pspd = Invoice.pspd,
|
||||
scc = Invoice.scc,
|
||||
scln = Invoice.scln,
|
||||
seventeentax = Invoice.seventeentax,
|
||||
tinc = Invoice.tinc,
|
||||
invoiceDetails = Invoice.invoiceDetails.Select(s => new InvoiceItem
|
||||
{
|
||||
CODID = s.CODID,
|
||||
am = s.am,
|
||||
fee = s.fee,
|
||||
dis = s.dis,
|
||||
|
||||
bros = s.bros,
|
||||
bsrn = s.bsrn,
|
||||
consfee = s.consfee,
|
||||
cut = s.cut,
|
||||
exr = s.exr,
|
||||
nw = s.nw,
|
||||
odam = s.odam,
|
||||
odr = s.odr,
|
||||
odt = s.odt,
|
||||
olam = s.olam,
|
||||
olr = s.olr,
|
||||
olt = s.olt,
|
||||
spro = s.spro,
|
||||
sscv = s.sscv,
|
||||
ssrv = s.ssrv
|
||||
}).ToList()
|
||||
}, false);
|
||||
if (result2 > 0)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Back.Common;
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -74,5 +75,61 @@ namespace Back.Controllers
|
||||
}
|
||||
else return BadRequest(new List<string> { "در این وضعیت امکان ابطال نیست" });
|
||||
}
|
||||
[HttpPost("AddOrder")]
|
||||
public async Task<ActionResult<OrderDto>> AddOrder(PromotionDto item)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
int CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
Order order = new Order();
|
||||
order = new Order()
|
||||
{
|
||||
CompanyID = CompanyID,
|
||||
ApprovalDate = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
DateCreate = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
Status = StatusOrder.Create,
|
||||
UserID = Convert.ToInt32(UserID)
|
||||
};
|
||||
if (item.ID<0)
|
||||
{
|
||||
var pricing = await _servPricing.GetPricing();
|
||||
//permission
|
||||
order.OrderItems = item.promotionDetails.Select(s => new OrderItem
|
||||
{
|
||||
APrice = pricing.Where(w => w.PermissionID == s.PermissionID).Select(c => c.Price).FirstOrDefault(),
|
||||
PermissionID = s.PermissionID,
|
||||
Discount=0,
|
||||
Tax=0,
|
||||
CreditAmount=s.CreditAmount
|
||||
}).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
//promotion
|
||||
var pro=await _servPromotion.GetByPromotionID(item.ID);
|
||||
if (pro == null)
|
||||
return NotFound();
|
||||
|
||||
order.OrderItems=new List<OrderItem>()
|
||||
{
|
||||
new OrderItem()
|
||||
{
|
||||
PromotionID=pro.ID,
|
||||
APrice=pro.PromotionDetails.Sum(s=>s.TPrice),
|
||||
CreditAmount=1,
|
||||
Tax=0,
|
||||
Discount=0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var result= await _servOrders.AddOrder(order);
|
||||
if (result > 0)
|
||||
return Ok(result);
|
||||
else return BadRequest(new List<string> { "خطا در ثبت سفارش" });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -70,5 +70,18 @@ namespace Back.Services
|
||||
{
|
||||
return await _repoOrder.UpdateAsync(order);
|
||||
}
|
||||
public async Task<int> AddOrder(Order order)
|
||||
{
|
||||
try
|
||||
{
|
||||
var item = await _repoOrder.AddAsync(order);
|
||||
return item.ID;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return -1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,5 +37,11 @@ namespace Back.Services
|
||||
}).ToList()
|
||||
}).ToListAsync();
|
||||
}
|
||||
public async Task<Promotion> GetByPromotionID(int PromotionID)
|
||||
{
|
||||
return await _repoPromotion.Get(w => w.Status && w.ID == PromotionID)
|
||||
.Include(inc => inc.PromotionDetails).ThenInclude(tinc => tinc.Permission)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -163,7 +163,7 @@
|
||||
{
|
||||
var itemFac= Selected.promotionDetails.Where(w => w.PermissionID == 3).FirstOrDefault();
|
||||
if (itemFac!=null)
|
||||
itemFac.CreditAmount = values[0];
|
||||
itemFac.CreditAmount = values[0];
|
||||
|
||||
var itemcod = Selected.promotionDetails.Where(w => w.PermissionID == 4).FirstOrDefault();
|
||||
if (itemcod != null)
|
||||
@@ -180,10 +180,44 @@
|
||||
TotalPrice = Selected.TotalPrice;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async Task NewOrder()
|
||||
{
|
||||
|
||||
if (Selected!=null)
|
||||
{
|
||||
//---------
|
||||
var itemFac = Selected.promotionDetails.Where(w => w.PermissionID == 3).FirstOrDefault();
|
||||
if (itemFac != null)
|
||||
itemFac.CreditAmount = values[0];
|
||||
|
||||
var itemcod = Selected.promotionDetails.Where(w => w.PermissionID == 4).FirstOrDefault();
|
||||
if (itemcod != null)
|
||||
itemcod.CreditAmount = values[1];
|
||||
|
||||
var itemcus = Selected.promotionDetails.Where(w => w.PermissionID == 5).FirstOrDefault();
|
||||
if (itemcus != null)
|
||||
itemcus.CreditAmount = values[2];
|
||||
|
||||
var itemtax = Selected.promotionDetails.Where(w => w.PermissionID == 16).FirstOrDefault();
|
||||
if (itemtax != null)
|
||||
itemtax.CreditAmount = values[3];
|
||||
//---------
|
||||
var rsp = await hc.Post<PromotionDto>($"Orders/AddOrder", Selected);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
|
||||
}
|
||||
else if (rsp.StatusCode==System.Net.HttpStatusCode.NotFound)
|
||||
{
|
||||
// ShowDangerAlert("سفارش یافت نشد");
|
||||
}
|
||||
else
|
||||
{
|
||||
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
// ShowDangerAlert(request[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user