public async Task <Tuple <bool, string> > ApplyFeeReimbursement() { FeeReimbursementModel applyFeeReimbursementModel = new FeeReimbursementModel(); string fileUploadPath = ConfigurationManager.AppSettings["FileUploadPath"].ToString(); Tuple <bool, string> resTuple = null; string filePath = string.Empty; string[] headerColumns = new string[0]; Regex csvParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))"); try { if (!Directory.Exists(fileUploadPath)) { Directory.CreateDirectory(fileUploadPath); } else { Array.ForEach(Directory.GetFiles(fileUploadPath), delegate(string path) { File.Delete(path); }); } var provider = new MultipartFormDataStreamProvider(fileUploadPath); var result = await Request.Content.ReadAsMultipartAsync(provider); if (result.FormData == null) { return(Tuple.Create(false, "BadRequest")); } var formData = result.FormData; foreach (var prop in typeof(FeeReimbursementModel).GetProperties()) { var curVal = formData[prop.Name]; if (curVal != null && !string.IsNullOrEmpty(curVal)) { prop.SetValue(applyFeeReimbursementModel, To(curVal, prop.PropertyType), null); } } if (UserID == null) { return(Tuple.Create(false, "User not Authenticated")); } if (result.FileData.Count > 0) { resTuple = await _repoLoans.ApplyFeeReimbursement(applyFeeReimbursementModel, result.FileData.ToList(), fileUploadPath); } else { resTuple = Tuple.Create(false, "There has been an error while applying fee reimbursement."); } } catch (Exception ex) { ErrorLog.Write(ex); } return(resTuple); }