public JsonResult FormPost(FormCollection formValues)
        {
            string claimsAdviceData  = Request.Form["claimsAdvice"];
            var    dateformat        = "dd/MM/yyyy";
            var    dateTimeConverter = new IsoDateTimeConverter {
                DateTimeFormat = dateformat
            };
            ClaimAdvice claimAdvice = JsonConvert.DeserializeObject <ClaimAdvice>(claimsAdviceData, dateTimeConverter);

            claimAdvice = RemoveEmptyItems(claimAdvice);

            List <HttpPostedFileBase> fileCollection = new List <HttpPostedFileBase>();

            try
            {
                foreach (string file in Request.Files)
                {
                    var fileContent = Request.Files[file];
                    if (fileContent != null && fileContent.ContentLength > 0)
                    {
                        fileCollection.Add(fileContent);
                    }
                }
            }
            catch (Exception ex)
            {
                WriteCustomErrorLog.WriteLog("Error occured while adding file collection");
                throw new Exception(ex.Message);
            }

            List <string> attachmentFilesPath = new FileHandler().fileSave(fileCollection, claimAdvice.ContactEmail + DateTime.Now.ToString("ddMMyyhhmmsstt"));

            fileCollection.Clear();

            IDictionary <string, string> Configurations = PickeringsRepository.GetConfigurationSetting();

            ClaimAdvice storedClaimAdvice = PickeringsRepository.StoreClaimAdvice(claimAdvice, attachmentFilesPath, Configurations["DatabaseRecoveryPath"]);

            Thread MailThread = new Thread(new ThreadStart(delegate()
            {
                SendMail(attachmentFilesPath, storedClaimAdvice, Configurations);
            }));

            MailThread.Start();

            string[] referenceNumber = { claimAdvice.ReferenceNumber, string.Format("{0:dd/MM/yy hh:mm:ss tt}", storedClaimAdvice.CreationDate) };
            return(Json(referenceNumber, JsonRequestBehavior.AllowGet));
        }
        public JsonResult AllInsuredDetails()
        {
            List <InsuredDropDown> insuredDetails;

            try
            {
                insuredDetails = new PickeringsRepository().GetAllInsured();
            }
            catch (Exception ex)
            {
                WriteCustomErrorLog.WriteLog("Database error while fetching all insured details");
                throw new Exception(ex.Message);
            }

            return(Json(insuredDetails, JsonRequestBehavior.AllowGet));
        }