public void CreateMarginBL_WithParameters_Ok()
        {
            IMarginDataAccess marginDataAccess = new MarginDataAccess();

            IMarginBusinessLogic marginBL = new MarginBusinessLogic(marginDataAccess);

            Assert.IsNotNull(marginBL);
        }
예제 #2
0
 public IHttpActionResult Post([FromBody] MarginModel marginModel)
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         MarginBusinessLogic.AddMargin(marginModel.ToEntity());
         return(Ok(marginModel));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
예제 #3
0
 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));
     }
 }
예제 #4
0
 public IHttpActionResult Get()
 {
     try
     {
         Utils.IsAValidToken(Request, AuthorizationBusinessLogic);
         var margins = MarginBusinessLogic.GetMargins();
         IList <MarginModel> marginsModel = MarginModel.ToModel(margins).ToList();
         return(Ok(marginsModel));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
예제 #5
0
 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));
     }
 }
예제 #6
0
        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));
            }
        }
예제 #7
0
        public IHttpActionResult Put([FromUri] Guid id, [FromBody] MarginModel marginModel)
        {
            try
            {
                Utils.IsAValidToken(Request, AuthorizationBusinessLogic);

                marginModel.Id = id;

                MarginBusinessLogic.ModifyMargin(marginModel.ToEntity());
                AuditLogBussinesLogic.CreateLog("Document", marginModel.DocumentId, Utils.GetUsername(Request), ActionPerformed.MODIFY);

                return(Ok(marginModel));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #8
0
        public void IntegrationTest_ExpectedParameters_Ok()
        {
            var requestMessage = new HttpRequestMessage();
            IMarginBusinessLogic        marginBL = new MarginBusinessLogic(new MarginDataAccess());
            IUserDataAccess             userDa   = new UserDataAccess();
            IAuthorizationBusinessLogic auth     = new AuthorizationBusinessLogic(userDa);
            IAuditLogBussinesLogic      audit    = new AuditLogBussinesLogic();
            MarginController            marginC  = new MarginController(marginBL, auth, audit);

            marginC.Request = requestMessage;
            MarginModel margin2 = MarginModel.ToModel(Utils.CreateMarginForTest());

            marginC.Post(marginModel);
            marginC.Post(margin2);
            marginC.Get(margin.Id);
            margin2.OwnStyleClass = "modified";
            marginC.Put(margin2.Id, margin2);
            marginC.Delete(marginModel.Id);
            IHttpActionResult statusObtained = marginC.Get();
        }
        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));
        }
        public void CreateMarginBL_WithoutParameters_Ok()
        {
            IMarginBusinessLogic marginBL = new MarginBusinessLogic();

            Assert.IsNotNull(marginBL);
        }