public async Task <IActionResult> insertMerchantContract([FromForm] int MerchantID, [FromForm] int MerchantrequestID)
        {
            try
            {
                strContractPath = _configuration["FilePath:ImagePath"] + "MerchantContract/";
                string strServerURL = _configuration["FilePath:ServerURL"] + "MerchantContract/";

                var file = Request.Form.Files[0];
                if (file != null)
                {
                    string fileName = string.Empty;
                    if (!Directory.Exists(strContractPath))
                    {
                        Directory.CreateDirectory(strContractPath);
                    }
                    if (file.Length > 0)
                    {
                        fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
                        string fullPath = Path.Combine(strContractPath, fileName);
                        using (var stream = new FileStream(fullPath, FileMode.Create))
                        {
                            file.CopyTo(stream);
                        }
                    }
                    InsertMerchantContractDto InsertMerchantContractDto = new InsertMerchantContractDto();
                    InsertMerchantContractDto.MerchantID        = MerchantID;
                    InsertMerchantContractDto.MerchantrequestID = MerchantrequestID;
                    InsertMerchantContractDto.ContractFilename  = fileName;
                    int MerchantContractID = await _MerchantContractService.CheckMerchantContract(MerchantID, MerchantrequestID);

                    if (MerchantContractID == 0)
                    {
                        await _MerchantContractService.InsertMerchantContract(InsertMerchantContractDto);

                        int getMerchantContractID = await _MerchantContractService.CheckMerchantContract(MerchantID, MerchantrequestID);

                        if (getMerchantContractID > 0)
                        {
                            await _MerchantContractDetailServices.InsertMerchantContractdetails(InsertMerchantContractDto, getMerchantContractID);
                        }
                    }
                    else
                    {
                        await _MerchantContractService.UpdateMerchantContract(InsertMerchantContractDto);

                        await _MerchantContractDetailServices.InsertMerchantContractdetails(InsertMerchantContractDto, MerchantContractID);
                    }
                }
                return(Ok(new GenericResultDto <string> {
                    Result = "Merchant Contract Upload Successfully"
                }));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new GenericResultDto <string> {
                    Result = ex.Message
                }));
            }
        }
示例#2
0
 public async Task InsertMerchantContractdetails(InsertMerchantContractDto InsertMerchantContractDto, int MerchantcontractID)
 {
     await Repository.InsertAsync(new MerchantContractDetails
     {
         MerchantcontractID = MerchantcontractID,
         ContractFileName   = InsertMerchantContractDto.ContractFilename,
     });
 }
 public async Task InsertMerchantContract(InsertMerchantContractDto InsertMerchantContractDto)
 {
     await Repository.InsertAsync(new MerchantContract
     {
         MerchantID              = InsertMerchantContractDto.MerchantID,
         MerchantrequestID       = InsertMerchantContractDto.MerchantrequestID,
         CurrentContractFileName = InsertMerchantContractDto.ContractFilename,
     });
 }
        public async Task UpdateMerchantContract(InsertMerchantContractDto InsertMerchantContractDto)
        {
            var MerchantContractDetails = Repository.SingleOrDefault(x => x.MerchantID == InsertMerchantContractDto.MerchantID);

            if (!string.IsNullOrEmpty(InsertMerchantContractDto.ContractFilename))
            {
                MerchantContractDetails.CurrentContractFileName = InsertMerchantContractDto.ContractFilename;
            }
            await Repository.UpdateAsync(MerchantContractDetails);
        }