CameraCar.Controllers.PhotoController.Take C# (CSharp) Method

Take() private method

private Take ( ) : System.Web.Mvc.ActionResult
return System.Web.Mvc.ActionResult
        public ActionResult Take()
        {
            var imagePath = Server.MapPath("~/App_Data/" + Guid.NewGuid().ToString("N") + ".jpg");
            #if DEBUG
            System.IO.File.Copy(Server.MapPath("~/App_Data/penguin.jpg"), imagePath);
            #else
            lock (_syncFswebcam)
            Process.Start("fswebcam", "-q -r 1024 --jpeg 95 --no-banner " + imagePath)
               .WaitForExit();
            #endif
            lock (_syncTakePhoto)
            {
                var saveDir = Server.MapPath("~/App_Data");
                var files = System.IO.Directory.GetFiles(saveDir, "*.jpg");
                var savePath = Enumerable.Range(0, int.MaxValue)
                    .Select(n => Path.Combine(saveDir, string.Format("photo{0:D3}.jpg", n)))
                    .First(path => files.Contains(path) == false);
                System.IO.File.Move(imagePath, savePath);
            }
            return new HttpStatusCodeResult(HttpStatusCode.OK);
        }