public HttpResponseMessage QuoteImport() { //var serviceResponse = new ServiceResponse(); //HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Found); HttpResponseMessage response = new HttpResponseMessage(); var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { HttpPostedFile file = httpRequest.Files[0]; //return Request.CreateResponse(HttpStatusCode.BadRequest); if (file != null && file.ContentLength > 0) { long projectId = Convert.ToInt64(httpRequest.Form["ProjectId"]); long quoteId = Convert.ToInt64(httpRequest.Form["QuoteId"]); QuoteModel quoteModel = new QuoteModel { ProjectId = projectId, QuoteId = quoteId }; if (Path.GetExtension(file.FileName).ToLower() == ".xls" || Path.GetExtension(file.FileName).ToLower() == ".xlsx" || Path.GetExtension(file.FileName).ToLower() == ".csv") { var csvReader = new StreamReader(file.InputStream); var csv = new CsvHelper.CsvReader(csvReader); //serviceResponse = quoteService.ImportProductsFromCSV(this.CurrentUser, csv, quoteModel); quoteService.ImportProductsFromCSV(this.CurrentUser, csv, quoteModel); response = Request.CreateResponse(HttpStatusCode.Accepted); response.ReasonPhrase = "File imported successfully!"; } else if (Path.GetExtension(file.FileName).ToLower() == ".xml") { //serviceResponse = quoteService.ImportProductsFromXML(this.CurrentUser, file, quoteModel); quoteService.ImportProductsFromXML(this.CurrentUser, file, quoteModel); response = Request.CreateResponse(HttpStatusCode.Accepted); response.ReasonPhrase = "File imported successfully!"; } else { //serviceResponse.Messages.AddError(Resources.ResourceUI.InvalidFile); response = Request.CreateResponse(HttpStatusCode.NotAcceptable); response.ReasonPhrase = "Invalid File Format!"; } } } else { //serviceResponse.Messages.AddWarning("Import file is missing!"); response = Request.CreateResponse(HttpStatusCode.NotAcceptable); response.ReasonPhrase = "Import file is missing!"; } //return serviceResponse; return(response); }