コード例 #1
0
        public async Task <DataRespond> insertFormFileAsync([FromForm] FormFileRequest formFileRequest)
        {
            DataRespond data = new DataRespond();

            try
            {
                FormFile formFile = m_formFileResponsitory.getFormFileById(formFileRequest.formfileid);
                data.success = true;
                data.message = "update success";
                if (formFileRequest.giaychungnhanboiduong != null)
                {
                    deleteFile(formFile.giaychungnhanboiduong);
                    formFile.giaychungnhanboiduong = await uploadFile(formFileRequest.giaychungnhanboiduong);

                    m_formFileResponsitory.updateFormFile(formFile);
                    return(data);
                }
                if (formFileRequest.bantukiemdiem != null)
                {
                    deleteFile(formFile.bantukiemdiem);
                    formFile.bantukiemdiem = await uploadFile(formFileRequest.bantukiemdiem);

                    m_formFileResponsitory.updateFormFile(formFile);
                    return(data);
                }
                if (formFileRequest.nhanxetnguoihd != null)
                {
                    deleteFile(formFile.nhanxetnguoihd);
                    formFile.nhanxetnguoihd = await uploadFile(formFileRequest.nhanxetnguoihd);

                    m_formFileResponsitory.updateFormFile(formFile);
                    return(data);
                }
                if (formFileRequest.nhanxetchibo != null)
                {
                    deleteFile(formFile.nhanxetchibo);
                    formFile.nhanxetchibo = await uploadFile(formFileRequest.nhanxetchibo);

                    m_formFileResponsitory.updateFormFile(formFile);
                    return(data);
                }
                if (formFileRequest.quydinhketnap != null)
                {
                    deleteFile(formFile.quydinhketnap);
                    formFile.quydinhketnap = await uploadFile(formFileRequest.quydinhketnap);

                    m_formFileResponsitory.updateFormFile(formFile);
                    return(data);
                }
            }
            catch (Exception e)
            {
                data.message = e.Message;
                data.error   = e;
                data.success = false;
            }
            return(data);
        }