// PUT api/basicinformation/5
 public bool Put(int id, [FromBody] BasicInformaionEntities item)
 {
     if (id > 0)
     {
         return(_Basicinfo.UpdateEmployeebasicinfo(id, item));
     }
     return(false);
 }
        private async Task <HttpResponseMessage> UseMultipartFormDataStream()
        {
            string root     = HttpContext.Current.Server.MapPath("~/images");
            var    provider = new MultipartFormDataStreamProvider(root);
            MultipartFormDataContent mpfdc = new MultipartFormDataContent();



            // DEFINE THE PATH WHERE WE WANT TO SAVE THE FILES.
            string sPath = "";

            sPath = System.Web.Hosting.HostingEnvironment.MapPath("~/images/");

            System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;


            // CHECK THE FILE COUNT.
            for (int iCnt = 0; iCnt <= hfc.Count - 1; iCnt++)
            {
                System.Web.HttpPostedFile hpf = hfc[iCnt];
                var filepath            = string.Empty;
                var fileNamefuStamp     = string.Empty;
                var physicalPathfuStamp = string.Empty;
                if (hpf.ContentLength > 0)
                {
                    // CHECK IF THE SELECTED FILE(S) ALREADY EXISTS IN FOLDER. (AVOID DUPLICATE)
                    if (!File.Exists(sPath + Path.GetFileName(hpf.FileName)))
                    {
                        // SAVE THE FILES IN THE FOLDER.
                        Bitmap bitmapImage            = ResizeImage(hpf.InputStream, 200, 200);
                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
                        bitmapImage.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
                        var data = stream.ToArray();
                        // Random r = new Random();
                        // string code = r.Next().ToString();
                        // fileNamefuStamp = Path.GetFileName(code + hpf.FileName);
                        // physicalPathfuStamp = Path.Combine(Server.MapPath("~/Models/"), fileNamefuStamp);
                        //filepath = "\\images\\Partners\\" + code + x.FileName;
                        //filepath = code + file.FileName;
                        //File.WriteAllBytes(sPath + Path.GetFileName(hpf.FileName), (data as byte[]));
                        //file.SaveAs(Server.MapPath("~/images/Partners/" + fileNamefuStamp));
                        //hpf.SaveAs(sPath + Path.GetFileName(hpf.FileName));
                        // iUploadedCnt = iUploadedCnt + 1;
                        BasicInformaionEntities item = new BasicInformaionEntities();
                        item.EMPLOYEE_IMAGE = Path.GetFileName(hpf.FileName);

                        item.EMPIMG = data;
                        string s  = hpf.FileName;
                        int    ix = s.IndexOf('_');
                        //s = ix != -1 ? s.Substring(ix + 1) : s;
                        //using the ternary operator here is quite useless, better to write:
                        //yourStringVariable.Substring(0, ix);
                        s = s.Substring(0, ix);



                        int  id = Convert.ToInt32(new String(s.ToCharArray().Where(c => Char.IsDigit(c)).ToArray()));
                        bool b  = _Basicinfo.UpdateEmployeebasicinfo(id, item);
                    }
                }
                //else
                //{
                //    return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "");
                //}
            }

            var response = Request.CreateResponse();

            response.StatusCode = HttpStatusCode.OK;
            return(response);

            //var file = provider.FileData;

            //if (file != null && file. > 0)
            //{
            //   var filename = file.Headers.ContentDisposition.FileName;
            //    var path = Path.Combine(Server.MapPath("~/App_Data/"), fileName);
            //    file.SaveAs(path);
            //}

            //try
            //{
            //    await Request.Content.ReadAsMultipartAsync(provider);

            //    foreach (MultipartFileData file in provider.FileData)
            //    {
            //        var filename = file.Headers.ContentDisposition.FileName;
            //        Trace.WriteLine(filename);



            //        Trace.WriteLine("Server file path: " + file.LocalFileName);

            //        mpfdc.Add(new ByteArrayContent(File.ReadAllBytes(file.LocalFileName)), "File", filename);


            //         var path = Path.Combine(root, filename);

            //    }
            //    var response = Request.CreateResponse();
            //    response.Content = mpfdc;
            //    response.StatusCode = HttpStatusCode.OK;
            //    return response;
            //}
            //catch (System.Exception e)
            //{
            //    return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e);
            //}
        }