Fixes the Profiles administration

* Web.config:
* web.config:
* Web.csproj:
* Global.asax.cs:
* ValidateAjaxAttribute.cs:
* Profile.aspx:
* HomeController.cs:
* BlogsController.cs:
* WebCatalogExtensions.cs:
* GoogleController.cs:
* AccountController.cs:
* Profile.cs:
* EstimToPdfFormatter.MSAN.cs: 

* Makefile: Removes obsolete target "rsync-all"
Adds the new target "allrsync"


* FrontOfficeApiController.cs: Makes the code smaller and a better
  output in case of exception generating the Pdf or Tex outputs

* WorkFlowController.cs: makes code cleaner

* App.master: Gives the Profile method call an id parameter

* Estimate.aspx: Fixes the estimation id parameter name at querying
  the Pdf or Tex documents

* Estim.cs: see Estim.tt

* Estim.tt: Mo more exception at transforming null values from the
  contact section of the client profile
This commit is contained in:
Paul Schneider 2015-04-17 00:01:20 +02:00
commit 8e2c21a3db
20 changed files with 457 additions and 261 deletions

View file

@ -89,30 +89,10 @@ namespace Yavsc.ApiControllers
[AcceptVerbs ("GET")]
public HttpResponseMessage EstimateToTex (long id)
{
string texest = null;
try {
texest = estimateToTex (id);
} catch (TemplateException ex) {
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
new ObjectContent (typeof(string),
ex.Message, new ErrorHtmlFormatter (HttpStatusCode.NotAcceptable,
LocalizedText.DocTemplateException
))
};
} catch (Exception ex) {
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
new ObjectContent (typeof(string),
ex.Message, new ErrorHtmlFormatter (HttpStatusCode.InternalServerError,
LocalizedText.DocTemplateException))
};
}
string texest = estimateToTex (id);
if (texest == null)
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
new ObjectContent (typeof(string), "Not an estimation id:" + id,
new ErrorHtmlFormatter (HttpStatusCode.NotFound,
LocalizedText.Estimate_not_found))
};
throw new InvalidOperationException (
"Not an estimate");
return new HttpResponseMessage () {
Content = new ObjectContent (typeof(string),
texest,
@ -146,11 +126,11 @@ namespace Yavsc.ApiControllers
/// <returns>The to pdf.</returns>
/// <param name="estimid">Estimid.</param>
[AcceptVerbs("GET")]
public HttpResponseMessage EstimateToPdf (long estimid)
public HttpResponseMessage EstimateToPdf (long id)
{
string texest = null;
try {
texest = estimateToTex (estimid);
texest = estimateToTex (id);
} catch (TemplateException ex) {
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
new ObjectContent (typeof(string),
@ -167,7 +147,7 @@ namespace Yavsc.ApiControllers
}
if (texest == null)
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
new ObjectContent (typeof(string), "Not an estimation id:" + estimid,
new ObjectContent (typeof(string), "Not an estimation id:" + id,
new ErrorHtmlFormatter (HttpStatusCode.NotFound,
LocalizedText.Estimate_not_found))
};
@ -193,7 +173,7 @@ namespace Yavsc.ApiControllers
/// <param name="model">Model.</param>
[Authorize()]
[ValidateAjaxAttribute]
public HttpResponseMessage Register ([FromBody] RegisterModel model)
public HttpResponseMessage Register ([FromBody] RegisterClientModel model)
{
if (ModelState.IsValid) {
if (model.IsApprouved)
@ -225,6 +205,14 @@ namespace Yavsc.ApiControllers
case MembershipCreateStatus.Success:
if (!model.IsApprouved)
Yavsc.Helpers.YavscHelpers.SendActivationEmail (user);
ProfileBase prtu = ProfileBase.Create (model.UserName);
prtu.SetPropertyValue("Name",model.Name);
prtu.SetPropertyValue("Address",model.Address);
prtu.SetPropertyValue("CityAndState",model.CityAndState);
prtu.SetPropertyValue("Mobile",model.Mobile);
prtu.SetPropertyValue("Phone",model.Phone);
prtu.SetPropertyValue("ZipCode",model.ZipCode);
break;
default:
break;

View file

@ -7,11 +7,10 @@ using System.Web.Security;
using Yavsc;
using Yavsc.Model.WorkFlow;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.ModelBinding;
using Yavsc.Model.RolesAndMembers;
using Yavsc.Helpers;
using Yavsc.Model;
using System.Web.Http.Controllers;
namespace Yavsc.ApiControllers
{
@ -135,18 +134,6 @@ 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);
}
/// <summary>
/// Updates the writting.
/// </summary>