* Fixed the Pdf generation under Slackware
* Estimate view developpement
This commit is contained in:
@ -143,7 +143,7 @@ namespace Yavsc.Controllers
|
||||
return UserPost (BlogManager.GetPost (postid));
|
||||
}
|
||||
}
|
||||
string prevstr = App_GlobalResources.LocalizedText.Preview;
|
||||
string prevstr = LocalizedText.Preview;
|
||||
return UserPost (BlogManager.GetPost (user, title));
|
||||
}
|
||||
|
||||
|
@ -88,9 +88,12 @@ namespace Yavsc.ApiControllers
|
||||
[AcceptVerbs("GET")]
|
||||
public HttpResponseMessage GetEstimTex(long estimid)
|
||||
{
|
||||
string texest = getEstimTex (estimid);
|
||||
if (texest == null)
|
||||
throw new HttpRequestValidationException ("Not an estimation id:"+estimid);
|
||||
return new HttpResponseMessage () {
|
||||
Content = new ObjectContent (typeof(string),
|
||||
getEstimTex (estimid),
|
||||
texest,
|
||||
new SimpleFormatter ("text/x-tex"))
|
||||
};
|
||||
}
|
||||
@ -101,12 +104,21 @@ namespace Yavsc.ApiControllers
|
||||
Estimate e = WorkFlowManager.GetEstimate (estimid);
|
||||
tmpe.Session = new Dictionary<string,object>();
|
||||
tmpe.Session.Add ("estim", e);
|
||||
Profile pr = AccountController.GetProfile (e.Responsible);
|
||||
tmpe.Session.Add ("from", pr);
|
||||
tmpe.Session.Add ("to", pr);
|
||||
|
||||
Profile prpro = new Profile(ProfileBase.Create(e.Responsible));
|
||||
if (!prpro.IsBankable)
|
||||
throw new Exception ("NotBankable:"+e.Responsible);
|
||||
|
||||
Profile prcli = new Profile(ProfileBase.Create(e.Client));
|
||||
if (!prcli.IsBillable)
|
||||
throw new Exception ("NotBillable:"+e.Client);
|
||||
tmpe.Session.Add ("from", prpro);
|
||||
tmpe.Session.Add ("to", prcli);
|
||||
tmpe.Init ();
|
||||
return tmpe.TransformText ();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the estimate in pdf format from tex generation.
|
||||
/// </summary>
|
||||
@ -115,14 +127,7 @@ namespace Yavsc.ApiControllers
|
||||
public HttpResponseMessage GetEstimPdf(long estimid)
|
||||
{
|
||||
Estimate estim = WorkFlowManager.GetEstimate (estimid);
|
||||
|
||||
Profile prpro = new Profile(ProfileBase.Create(estim.Responsible));
|
||||
if (!prpro.IsBankable)
|
||||
throw new Exception ("NotBankable:"+estim.Responsible);
|
||||
|
||||
Profile prcli = new Profile(ProfileBase.Create(estim.Client));
|
||||
if (!prcli.IsBillable)
|
||||
throw new Exception ("NotBillable:"+estim.Client);
|
||||
//TODO better with pro.IsBankable && cli.IsBillable
|
||||
|
||||
return new HttpResponseMessage () {
|
||||
Content = new ObjectContent (
|
||||
|
@ -9,8 +9,8 @@ using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using Yavsc;
|
||||
using System.Reflection;
|
||||
using Yavsc.App_GlobalResources;
|
||||
using System.Resources;
|
||||
using Yavsc.Model;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user