public ConversionData Clone()
        {
            ConversionData data = new ConversionData();

            data.UserModel = this.UserModel.Clone();
            data.SessionId = this.SessionId;
            data.Operation = this.Operation;

            data.IsPreConversionFileSaved = this.IsPreConversionFileSaved;
            data.PreConversionFileName    = this.PreConversionFileName;

            data.IsPreConversionPaymentLoaded  = this.IsPreConversionPaymentLoaded;
            data.IsPreConversionPaymentSkipped = this.IsPreConversionPaymentSkipped;
            data.PreConversionPaymentFileName  = this.PreConversionPaymentFileName;

            data.IsPreConversionAgencyLoaded = this.IsPreConversionAgencyLoaded;
            data.PreConversionDefaultAgency  = this.PreConversionDefaultAgency;
            data.PreConversionAgencyFileName = this.PreConversionAgencyFileName;

            data.IsPreConversionAgencyPolicyLinked = this.IsPreConversionAgencyPolicyLinked;
            data.PreConversionAgencyPolicyFileName = this.PreConversionAgencyPolicyFileName;

            data.IsPreConversionExecutionCompleted  = this.IsPreConversionExecutionCompleted;
            data.IsConversionExecutionCompleted     = this.IsConversionExecutionCompleted;
            data.IsReconciliationExecutionCompleted = this.IsReconciliationExecutionCompleted;

            return(data);
        }
        public JsonResult Upload()
        {
            ConversionData request  = null;
            ConversionData response = null;

            HttpPostedFileBase file = null;

            try
            {
                request  = JsonConvert.DeserializeObject <ConversionData>(Request.Form[0]);
                response = request.Clone();
            }
            catch (Exception ex)
            {
                response = new ConversionData
                {
                    Error = ex.Message
                };
                return(this.Json(response));
            }

            try
            {
                if (Request.Files.Count > 0)
                {
                    HttpFileCollectionBase files = Request.Files;
                    request.FileName = Path.GetFileName(Request.Files[0].FileName);
                    file             = files[0];
                }
            }
            catch (Exception ex)
            {
                response.Error = ex.Message;
                return(this.Json(response));
            }

            switch (request.Operation)
            {
            case ConversionOperation.UploadPreConversion601:
            case ConversionOperation.UploadPreConversionPayment:
            case ConversionOperation.UploadPreConversionAgency:
            case ConversionOperation.UploadPreConversionAgencyPolicy:
                try
                {
                    request.FileContent = this.GetFileContent(file);
                }
                catch (Exception ex)
                {
                    response.Error = ex.Message;
                }
                break;
            }

            if (!response.HasError)
            {
                try
                {
                    switch (request.Operation)
                    {
                    case ConversionOperation.UploadPreConversion601:
                        //TODO:
                        response.IsPreConversionFileSaved = true;
                        break;

                    case ConversionOperation.UploadPreConversionPayment:
                        //TODO:
                        response.IsPreConversionPaymentLoaded = true;
                        break;

                    case ConversionOperation.UploadPreConversionAgency:
                        //TODO:
                        response.IsPreConversionAgencyLoaded = true;
                        break;

                    case ConversionOperation.UploadPreConversionAgencyPolicy:
                        //TODO:
                        response.IsPreConversionAgencyPolicyLinked = true;
                        break;

                    case ConversionOperation.ExecutePreConversion:
                        //TODO:
                        response.IsPreConversionExecutionCompleted = true;
                        break;

                    case ConversionOperation.ExecuteConversion:
                        //TODO:
                        response.IsConversionExecutionCompleted = true;
                        break;

                    case ConversionOperation.ExecuteReconciliation:
                        //TODO:
                        response.IsReconciliationExecutionCompleted = true;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    response.Error = ex.Message;
                }
            }

            return(this.Json(response));
        }