* LocalizedText.fr.resx: internationalisation de la saisie de
l'estimation * LocalizedText.resx: * FrontOfficeApiController.cs: renamed the Tex generation method * FrontOfficeController.cs: fixed the Estimate creation * WorkFlowController.cs: return model validation errors when updating a writting. * TexFormatter.cs: Simple mime-type content declaration * Global.asax.cs: * T4TemplateEstimate.cs: cleanning * BBCodeHelper.cs: BBCodes: docpage summary gone into a new aside element * App.master: thanks links are now contained in a div element * style.css: clearer * Estimate.aspx: Fixed the creation/edition/removal processes * Estim.tt: added the column "Count" to the writtings table. * RegisterViewModel.cs: internationalization * Writting.cs: stronger model * Estim.tex: cleaning
This commit is contained in:
parent
b4fefbce7e
commit
312585d4f0
16 changed files with 130 additions and 244 deletions
|
|
@ -86,16 +86,16 @@ namespace Yavsc.ApiControllers
|
|||
}
|
||||
|
||||
[AcceptVerbs("GET")]
|
||||
public HttpResponseMessage GetTexEstim(long estimid)
|
||||
public HttpResponseMessage GetEstimTex(long estimid)
|
||||
{
|
||||
return new HttpResponseMessage () {
|
||||
Content = new ObjectContent (typeof(string),
|
||||
getTexEstim (estimid),
|
||||
new TexFormatter ())
|
||||
getEstimTex (estimid),
|
||||
new SimpleFormatter ("text/x-tex"))
|
||||
};
|
||||
}
|
||||
|
||||
private string getTexEstim(long estimid)
|
||||
private string getEstimTex(long estimid)
|
||||
{
|
||||
Yavsc.templates.Estim tmpe = new Yavsc.templates.Estim();
|
||||
Estimate e = WorkFlowManager.GetEstimate (estimid);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ namespace Yavsc.Controllers
|
|||
[Authorize]
|
||||
public ActionResult Estimate(Estimate model,string submit)
|
||||
{
|
||||
ViewData ["WebApiBase"] = "http://" + Request.Url.Authority + "/api";
|
||||
ViewData ["WABASEWF"] = ViewData ["WebApiBase"] + "/WorkFlow";
|
||||
if (submit == null) {
|
||||
if (model.Id > 0) {
|
||||
Estimate f = WorkFlowManager.GetEstimate (model.Id);
|
||||
|
|
@ -41,27 +43,31 @@ namespace Yavsc.Controllers
|
|||
ModelState.Clear ();
|
||||
string username = HttpContext.User.Identity.Name;
|
||||
if (username != model.Responsible
|
||||
&& username != model.Client
|
||||
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||
&& username != model.Client
|
||||
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to view this estimate");
|
||||
|
||||
}
|
||||
} else if (ModelState.IsValid) {
|
||||
|
||||
ViewData ["WebApiUrl"] = "http://" + Request.Url.Authority + "/api/WorkFlow";
|
||||
} else {
|
||||
string username = HttpContext.User.Identity.Name;
|
||||
if (username != model.Responsible
|
||||
&& username != model.Client
|
||||
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
|
||||
if (model.Id == 0) {
|
||||
model.Responsible=username;
|
||||
ModelState.Clear ();
|
||||
}
|
||||
if (ModelState.IsValid) {
|
||||
if (username != model.Responsible
|
||||
&& username != model.Client
|
||||
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
|
||||
|
||||
if (model.Id == 0)
|
||||
if (model.Id == 0)
|
||||
model = WorkFlowManager.CreateEstimate (
|
||||
username,
|
||||
model.Client, model.Title, model.Description);
|
||||
else
|
||||
WorkFlowManager.UpdateEstimate (model);
|
||||
|
||||
}
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,14 +38,17 @@ namespace Yavsc.ApiControllers
|
|||
{
|
||||
WorkFlowManager.DropWritting (wrid);
|
||||
}
|
||||
class Error {}
|
||||
|
||||
[Authorize]
|
||||
[AcceptVerbs("POST")]
|
||||
public void UpdateWritting([FromBody] Writting wr)
|
||||
public object UpdateWritting([FromBody] Writting model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
throw new Exception ("Modèle invalide");
|
||||
WorkFlowManager.UpdateWritting (wr);
|
||||
if (!ModelState.IsValid) {
|
||||
return ModelState.Where ( k => k.Value.Errors.Count>0) ;
|
||||
}
|
||||
WorkFlowManager.UpdateWritting (model);
|
||||
return null;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
|
@ -67,8 +70,12 @@ namespace Yavsc.ApiControllers
|
|||
|
||||
[AcceptVerbs("POST")]
|
||||
[Authorize]
|
||||
public long Write ([FromUri] long estid, [FromBody] Writting wr) {
|
||||
// TODO ensure estid owner matches the current one
|
||||
/// <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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue