Пример #1
0
        public async Task <ActionResult <ProformaInvoiceMst> > UpdateOtherFile(int mstId)
        {
            try
            {
                string[] otherFilePathArr = new string[1];
                if (Request.Form.Files.Count > 0)
                {
                    var v          = Request.Form;
                    var file       = Request.Form.Files[0];
                    var folderName = Path.Combine("Resources", "ProformaDoc");
                    var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName);
                    if (file.Length > 0)
                    {
                        var gid      = Guid.NewGuid();
                        var fileName = gid + ".pdf";
                        var fullPath = Path.Combine(folderName, fileName);
                        // var dbPath = Path.Combine(folderName, fileName);
                        var dbPath = fileName;
                        otherFilePathArr[0] = dbPath;
                        using (var stream = new FileStream(fullPath, FileMode.Create))
                        {
                            file.CopyTo(stream);
                        }
                    }
                }
                ProformaInvoiceMst updatedProforma = await _proformaInvoiceRepository.UpdateOtherFilePath(mstId, otherFilePathArr);

                return(updatedProforma);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public async Task <ActionResult <ProformaInvoiceMst> > UploadProformaFiles(int id)
        {
            try
            {
                var      userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                string[] proformaFilePathArr = new string[4];
                for (int i = 0; i < Request.Form.Files.Count; i++)
                {
                    var v          = Request.Form;
                    var file       = Request.Form.Files[i];
                    var folderName = Path.Combine("Resources", "ProformaDoc");
                    var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName);
                    if (file.Length > 0)
                    {
                        var guid     = Guid.NewGuid();
                        var fileName = guid + ".pdf";
                        var fullPath = Path.Combine(folderName, fileName);
                        var dbPath   = fileName;
                        proformaFilePathArr[i] = dbPath;
                        using (var stream = new FileStream(fullPath, FileMode.Create))
                        {
                            file.CopyTo(stream);
                        }
                    }
                }
                ProformaInvoiceMst updatedProforma = await _proformaInvoiceRepository.UpdateProformaFilePath(id, proformaFilePathArr);

                return(updatedProforma);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public async Task <ActionResult <ProformaInvoiceMst> > SaveProformaInvoiceMst(ProformaInvoiceMst proformaInvoiceMst)
        {
            ProformaInvoiceMst proformaMst = null;

            if (proformaInvoiceMst != null)
            {
                proformaMst = await _proformaInvoiceRepository.SaveProformaInvoiceMst(proformaInvoiceMst);
            }
            return(proformaMst);
        }
Пример #4
0
        public async Task <ProformaInvoiceMst> UpdateOtherFilePath(int mstId, string[] Arr)
        {
            ProformaInvoiceMst targetedProforma = await _nmsDataContext.ProformaInvoiceMsts.FirstOrDefaultAsync(x => x.Id == mstId);

            targetedProforma.OtherDoc = Arr[0] == null ? null : Arr[0].Replace("\\", "/");
            if (mstId > 0 && targetedProforma != null)
            {
                _nmsDataContext.ProformaInvoiceMsts.Attach(targetedProforma);
                await _nmsDataContext.SaveChangesAsync();
            }
            return(targetedProforma);
        }
Пример #5
0
        public async Task <ProformaInvoiceMst> UpdateProformaFilePath(int id, string[] Arr)
        {
            ProformaInvoiceMst targetedProforma = await _nmsDataContext.ProformaInvoiceMsts.FirstOrDefaultAsync(i => i.Id == id);

            targetedProforma.PiScan     = Arr[0] == null ? null : Arr[0].Replace("\\", "/");
            targetedProforma.LitScan    = Arr[1] == null ? null : Arr[1].Replace("\\", "/");
            targetedProforma.TestReport = Arr[2] == null ? null : Arr[2].Replace("\\", "/");
            targetedProforma.OtherDoc   = Arr[3] == null ? null : Arr[3].Replace("\\", "/");
            if (id > 0 && targetedProforma != null)
            {
                _nmsDataContext.ProformaInvoiceMsts.Attach(targetedProforma);
                await _nmsDataContext.SaveChangesAsync();
            }
            return(targetedProforma);
        }
Пример #6
0
        public async Task <ProformaInvoiceMst> SaveProformaInvoiceMst(ProformaInvoiceMst proformaInvoiceMst)
        {
            var today         = DateTime.Now;
            var formattedDate = today.ToString("ddMMyyyy"); //+ today.Month.ToString() + today.Year.ToString();

            if (formattedDate.Length < 6)
            {
                formattedDate = "0" + formattedDate;
            }
            var totalProforma = await _nmsDataContext.ProformaInvoiceMsts.ToListAsync();

            proformaInvoiceMst.ApplicationNo     = formattedDate + (totalProforma.Count() + 1).ToString();
            proformaInvoiceMst.ProformaInvoiceNo = (totalProforma.Count() + 1).ToString();
            proformaInvoiceMst.ProformaDate      = DateTime.Now;
            proformaInvoiceMst.SubmissionDate    = null;
            await _nmsDataContext.ProformaInvoiceMsts.AddAsync(proformaInvoiceMst);

            await _nmsDataContext.SaveChangesAsync();

            return(proformaInvoiceMst);
        }