refactoring & getting signs
This commit is contained in:
parent
812d523068
commit
5dbc4d4f7c
9 changed files with 47 additions and 11 deletions
|
|
@ -84,6 +84,7 @@ namespace Yavsc.ApiControllers
|
||||||
return ViewComponent("Estimate",new object[] { id, "Pdf" } );
|
return ViewComponent("Estimate",new object[] { id, "Pdf" } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost("prosign/{id}")]
|
[HttpPost("prosign/{id}")]
|
||||||
public async Task<IActionResult> ProSign(long id)
|
public async Task<IActionResult> ProSign(long id)
|
||||||
{
|
{
|
||||||
|
|
@ -97,7 +98,7 @@ namespace Yavsc.ApiControllers
|
||||||
}
|
}
|
||||||
if (Request.Form.Files.Count!=1)
|
if (Request.Form.Files.Count!=1)
|
||||||
return new BadRequestResult();
|
return new BadRequestResult();
|
||||||
User.ReceiveSignature(id,Request.Form.Files[0],"pro");
|
User.ReceiveProSignature(id,Request.Form.Files[0],"pro");
|
||||||
estimate.ProviderValidationDate = DateTime.Now;
|
estimate.ProviderValidationDate = DateTime.Now;
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
// Notify the client
|
// Notify the client
|
||||||
|
|
@ -107,6 +108,22 @@ namespace Yavsc.ApiControllers
|
||||||
return Ok (new { ProviderValidationDate = estimate.ProviderValidationDate, GCMSent = grep.success });
|
return Ok (new { ProviderValidationDate = estimate.ProviderValidationDate, GCMSent = grep.success });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("prosign/{id}")]
|
||||||
|
public async Task<IActionResult> GetProSign(long id)
|
||||||
|
{
|
||||||
|
// For authorization purpose
|
||||||
|
var estimate = dbContext.Estimates.FirstOrDefault(e=>e.Id == id);
|
||||||
|
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||||
|
{
|
||||||
|
return new ChallengeResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
var filename = FileSystemHelpers.SignFileNameFormat("pro",id);
|
||||||
|
FileInfo fi = new FileInfo(Path.Combine(Startup.UserBillsDirName, filename));
|
||||||
|
if (!fi.Exists) return HttpNotFound(new { Error = "Professional signature not found" });
|
||||||
|
return File(fi.OpenRead(), "application/x-pdf", filename); ;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost("clisign/{id}")]
|
[HttpPost("clisign/{id}")]
|
||||||
public async Task<IActionResult> CliSign(long id)
|
public async Task<IActionResult> CliSign(long id)
|
||||||
{
|
{
|
||||||
|
|
@ -119,11 +136,26 @@ namespace Yavsc.ApiControllers
|
||||||
}
|
}
|
||||||
if (Request.Form.Files.Count!=1)
|
if (Request.Form.Files.Count!=1)
|
||||||
return new BadRequestResult();
|
return new BadRequestResult();
|
||||||
User.ReceiveSignature(id,Request.Form.Files[0],"cli");
|
User.ReceiveProSignature(id,Request.Form.Files[0],"cli");
|
||||||
estimate.ClientValidationDate = DateTime.Now;
|
estimate.ClientValidationDate = DateTime.Now;
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
return Ok (new { ClientValidationDate = estimate.ClientValidationDate });
|
return Ok (new { ClientValidationDate = estimate.ClientValidationDate });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("clisign/{id}")]
|
||||||
|
public async Task<IActionResult> GetCliSign(long id)
|
||||||
|
{
|
||||||
|
// For authorization purpose
|
||||||
|
var estimate = dbContext.Estimates.FirstOrDefault(e=>e.Id == id);
|
||||||
|
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||||
|
{
|
||||||
|
return new ChallengeResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
var filename = FileSystemHelpers.SignFileNameFormat("pro",id);
|
||||||
|
FileInfo fi = new FileInfo(Path.Combine(Startup.UserBillsDirName, filename));
|
||||||
|
if (!fi.Exists) return HttpNotFound(new { Error = "Professional signature not found" });
|
||||||
|
return File(fi.OpenRead(), "application/x-pdf", filename); ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
@ -169,10 +170,13 @@ namespace Yavsc.Helpers
|
||||||
dir, xsmallname), ImageFormat.Png);
|
dir, xsmallname), ImageFormat.Png);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static FileRecievedInfo ReceiveSignature(this ClaimsPrincipal user, long estimateId, IFormFile formFile, string signtype)
|
public static Func<string,long,string>
|
||||||
|
SignFileNameFormat = new Func<string,long,string> ((signType,estimateId) => $"estimate-{signType}sign-{estimateId}.png");
|
||||||
|
|
||||||
|
public static FileRecievedInfo ReceiveProSignature(this ClaimsPrincipal user, long estimateId, IFormFile formFile, string signtype)
|
||||||
{
|
{
|
||||||
var item = new FileRecievedInfo();
|
var item = new FileRecievedInfo();
|
||||||
item.FileName = $"estimate-{signtype}sign-{estimateId}.png";
|
item.FileName = SignFileNameFormat("pro",estimateId);
|
||||||
var destFileName = Path.Combine(Startup.SiteSetup.UserFiles.Bills, item.FileName);
|
var destFileName = Path.Combine(Startup.SiteSetup.UserFiles.Bills, item.FileName);
|
||||||
|
|
||||||
var fi = new FileInfo(destFileName);
|
var fi = new FileInfo(destFileName);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models.Process
|
||||||
{
|
{
|
||||||
public abstract class Action<TResult,TInput>
|
public abstract class Action<TResult,TInput>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models.Process
|
||||||
{
|
{
|
||||||
public class Conjonction : List<IRequisition>, IRequisition
|
public class Conjonction : List<IRequisition>, IRequisition
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models.Process
|
||||||
{
|
{
|
||||||
public class Disjonction : List<IRequisition>, IRequisition
|
public class Disjonction : List<IRequisition>, IRequisition
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models.Process
|
||||||
{
|
{
|
||||||
public class ConstInputValue : NamedRequisition
|
public class ConstInputValue : NamedRequisition
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models.Process
|
||||||
{
|
{
|
||||||
public abstract class NamedRequisition : IRequisition
|
public abstract class NamedRequisition : IRequisition
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models.Process
|
||||||
{
|
{
|
||||||
public class Negation<Exp> : IRequisition where Exp : IRequisition
|
public class Negation<Exp> : IRequisition where Exp : IRequisition
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Yavsc.Models
|
namespace Yavsc.Models.Process
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An abstract, identified rule
|
/// An abstract, identified rule
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue