Пример #1
0
        public async Task <ProformaInvoiceMst> UpdateProformaInvoiceMst(ProformaInvoiceMstUpdateDto proformaInvoiceMstUpdateDto)
        {
            var proMst = await _nmsDataContext.ProformaInvoiceMsts.FirstOrDefaultAsync(x => x.Id == proformaInvoiceMstUpdateDto.Id);

            proMst.Currency        = proformaInvoiceMstUpdateDto.Currency;
            proMst.CountryOfOrigin = proformaInvoiceMstUpdateDto.CountryOfOrigin;
            proMst.PortOfLoading   = proformaInvoiceMstUpdateDto.PortOfLoading;
            proMst.PortOfEntry     = proformaInvoiceMstUpdateDto.PortOfEntry;
            _nmsDataContext.ProformaInvoiceMsts.Attach(proMst);
            await _nmsDataContext.SaveChangesAsync();

            return(proMst);
        }
Пример #2
0
        public async Task <ActionResult <ProformaInvoiceMst> > UpdateProformaInvoiceMst(ProformaInvoiceMstUpdateDto proformaInvoiceMstUpdateDto)
        {
            if (proformaInvoiceMstUpdateDto.Id < 1)
            {
                return(BadRequest());
            }
            var userId = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var res    = await _proformaInvoiceRepository.ValidateUpdateProMstClaim(proformaInvoiceMstUpdateDto.Id, userId);

            if (res == false)
            {
                return(BadRequest());
            }
            var result = await _proformaInvoiceRepository.IsProformaSubmitted(proformaInvoiceMstUpdateDto.Id);

            if (result.IsSubmitted == true)
            {
                return(BadRequest());
            }
            var proMst = await _proformaInvoiceRepository.UpdateProformaInvoiceMst(proformaInvoiceMstUpdateDto);

            return(proMst);
        }