* Fixed the Pdf generation under Slackware

* Estimate view developpement
This commit is contained in:
Paul Schneider 2014-11-03 16:55:09 +01:00
commit f695d108fb
27 changed files with 459 additions and 242 deletions

View file

@ -2,12 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using WorkFlowProvider;
using Yavsc.Model.WorkFlow;
using System.Web.Http.Controllers;
using System.Web.Security;
using System.Web.Http.ModelBinding;
using System.Net.Http;
using System.Web.Http;
namespace Yavsc.ApiControllers
{
@ -38,18 +39,8 @@ namespace Yavsc.ApiControllers
{
WorkFlowManager.DropWritting (wrid);
}
class Error {}
[Authorize]
[AcceptVerbs("POST")]
public object UpdateWritting([FromBody] Writting model)
{
if (!ModelState.IsValid) {
return ModelState.Where ( k => k.Value.Errors.Count>0) ;
}
WorkFlowManager.UpdateWritting (model);
return null;
}
[HttpGet]
[Authorize]
@ -67,17 +58,54 @@ namespace Yavsc.ApiControllers
return new { test=string.Format("Hello {0}!",username) };
}
private HttpResponseMessage CreateModelStateErrorResponse () {
// strip exceptions
Dictionary<string,string[]> errs = new Dictionary<string, string[]> ();
foreach (KeyValuePair<string,ModelState> st
in ModelState.Where (x => x.Value.Errors.Count > 0))
errs.Add(st.Key, st.Value.Errors.Select(x=>x.ErrorMessage).ToArray());
return Request.CreateResponse(System.Net.HttpStatusCode.BadRequest,
errs);
}
[Authorize]
[AcceptVerbs("POST")]
[ValidateAjax]
public HttpResponseMessage UpdateWritting([FromBody] Writting wr)
{
WorkFlowManager.UpdateWritting (wr);
return Request.CreateResponse (System.Net.HttpStatusCode.OK);
}
[AcceptVerbs("POST")]
[Authorize]
[ValidateAjax]
/// <summary>
/// Adds the specified imputation to the given estimation by estimation id.
/// </summary>
/// <param name="estid">Estimation identifier</param>
/// <param name="wr">Imputation to add</param>
public long Write ([FromUri] long estid, Writting wr) {
return WorkFlowManager.Write(estid, wr.Description,
wr.UnitaryCost, wr.Count, wr.ProductReference);
public HttpResponseMessage Write ([FromUri] long estid, [FromBody] Writting wr) {
if (estid <= 0) {
ModelState.AddModelError ("EstimationId", "Spécifier un identifiant d'estimation valide");
return Request.CreateResponse (System.Net.HttpStatusCode.BadRequest,
ValidateAjaxAttribute.GetErrorModelObject (ModelState));
}
try {
return Request.CreateResponse(System.Net.HttpStatusCode.OK,
WorkFlowManager.Write(estid, wr.Description,
wr.UnitaryCost, wr.Count, wr.ProductReference));
}
catch (Exception ex) {
return Request.CreateResponse (
System.Net.HttpStatusCode.InternalServerError,
"Internal server error:" + ex.Message + "\n" + ex.StackTrace);
}
}
}
}