public ActionResult ConsignmentContractTemplate()
        {
            string   filePath         = DiffMethods.TemplateDifferentOnDisk("ConsignmentContract.txt");
            FileInfo fileInfo         = new FileInfo(filePath);
            string   contractTemplate = fileInfo.Exists ? System.IO.File.ReadAllText(filePath) : string.Empty;

            ViewData["ContractTemplate"] = contractTemplate;
            return(View());
        }
 public JsonResult ResetConsignmentContract(long consignmentID)
 {
     try
     {
         var consignmentContract = AuctionRepository.GetConsignmentContract(consignmentID);
         var consignment         = AuctionRepository.GetConsignment(consignmentID);
         if (consignmentContract == null || consignment == null)
         {
             throw new Exception("Consignment does not exist.");
         }
         if (consignmentContract.StatusID == (int)Consts.ConsignmentContractStatus.Signed)
         {
             throw new Exception("The contract is already signed by seller.");
         }
         var filePath         = DiffMethods.TemplateDifferentOnDisk("ConsignmentContract.txt");
         var fileInfo         = new FileInfo(filePath);
         var contractTemplate = string.Empty;
         if (fileInfo.Exists)
         {
             contractTemplate = System.IO.File.ReadAllText(filePath);
             var buyerFee    = consignment.Event.BuyerFee.GetValueOrDefault(0).GetPrice();
             var buyerFeeStr = buyerFee.ToString();
             if (buyerFee == (int)buyerFee)
             {
                 buyerFeeStr = buyerFeeStr.Remove(buyerFeeStr.Length - 3);
             }
             contractTemplate =
                 contractTemplate.Replace("{{BuyersPremium}}", string.Format("{0}%", buyerFeeStr))
                 .Replace("{{CommissionRate}}", consignment.User.CommissionRate.LongDescription);
         }
         if (!string.IsNullOrWhiteSpace(consignmentContract.FileName))
         {
             fileInfo =
                 new FileInfo(DiffMethods.ConsignmentContractOnDisk(consignmentID, consignmentContract.FileName));
             if (fileInfo.Exists)
             {
                 fileInfo.Delete();
             }
         }
         consignmentContract.UpdateFields(consignmentContract.ConsignmentID,
                                          (int)Consts.ConsignmentContractStatus.NotGenerated, contractTemplate, string.Empty);
         AuctionRepository.UpdateConsignmentContract(consignmentContract);
         return
             (JSON(new JsonExecuteResult(JsonExecuteResultTypes.SUCCESS, "Contract was reset to default.",
                                         new
         {
             StatusText = Consts.ConsignmentContractStatus.NotGenerated.ToString(),
             ContractText = contractTemplate
         })));
     }
     catch (Exception exc)
     {
         return(JSON(new JsonExecuteResult(JsonExecuteResultTypes.ERROR, exc.Message)));
     }
 }
 public JsonResult SaveConsignmentContractTemplate(string textTemplate)
 {
     try
     {
         string filePath = DiffMethods.TemplateDifferentOnDisk("ConsignmentContract.txt");
         System.IO.File.WriteAllText(filePath, textTemplate);
     }
     catch (Exception exc)
     {
         return(JSON(new JsonExecuteResult(JsonExecuteResultTypes.ERROR, exc.Message)));
     }
     return(JSON(new JsonExecuteResult(JsonExecuteResultTypes.SUCCESS, "Data was saved successfully")));
 }