public IHttpActionResult Get([FromUri] Guid id) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); var margin = MarginBusinessLogic.GetMargin(id); return(Ok(MarginModel.ToModel(margin))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IHttpActionResult Put([FromUri] Guid id) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); Guid documentId = MarginBusinessLogic.GetMargin(id).DocumentId.Value; MarginBusinessLogic.ClearText(id); AuditLogBussinesLogic.CreateLog("Document", documentId, Utils.GetUsername(Request), ActionPerformed.MODIFY); return(Ok("Texts clear")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IHttpActionResult Put([FromUri] Guid marginId, [FromBody] TextModel textModel) { try { Utils.IsAValidToken(Request, AuthorizationBusinessLogic); var text = TextModel.ToEntity(textModel); Guid documentId = MarginBusinessLogic.GetMargin(marginId).DocumentId.Value; MarginBusinessLogic.SetText(marginId, text); AuditLogBussinesLogic.CreateLog("Document", documentId, Utils.GetUsername(Request), ActionPerformed.MODIFY); return(Ok(textModel)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void IntegrationTest_ExpectedParameters_Ok() { MarginDataAccess marginDA = new MarginDataAccess(); MarginBusinessLogic marginBL = new MarginBusinessLogic(marginDA); Margin margin1 = Utils.CreateMarginForTest(); Margin margin2 = Utils.CreateMarginForTest(); marginBL.AddMargin(margin1); marginBL.AddMargin(margin2); margin2.SetText(text); marginBL.ModifyMargin(margin2); marginBL.DeleteMargin(margin1.Id); Margin margin2Obtained = marginBL.GetMargin(margin2.Id); IList <Margin> marginsObtained = marginBL.GetMargins(); Assert.IsTrue(!marginsObtained.Contains(margin1) && marginsObtained.Contains(margin2Obtained)); }