Esempio n. 1
0
        public ResultValue <AccountCanvasDto> CreateAccount(AccountSaveParameters parameters)
        {
            var result = new ResultValue <AccountCanvasDto>();
            var url    = API_URL + parameters.ParentAccountId + "/sub_accounts";
            var param  = new
            {
                account = new
                {
                    sis_account_id = parameters.Estudio.Id + "-" + parameters.IdPeriodoMatriculacion,
                    name           = parameters.Name
                }
            };
            var returnData = base.Post(url, param);
            var logData    = returnData as LogDto;

            if (logData != null)
            {
                var idLog = _logService.SaveLog(logData);
                result.Errors.Add(string.Format(CanvasApiStrings.ErrorApi, idLog));
                return(result);
            }
            result.Value = new AccountCanvasDto
            {
                Id            = returnData["id"],
                Name          = returnData["name"],
                SisId         = returnData["sis_account_id"],
                WorkflowState = returnData["workflow_state"],
                ParentId      = returnData["parent_account_id"]
            };
            return(result);
        }
Esempio n. 2
0
        public ResultValue <AccountCanvasDto> Update(AccountSaveParameters parameters)
        {
            var result = new ResultValue <AccountCanvasDto>();
            var url    = API_URL + parameters.Id;
            var param  = new
            {
                account = new
                {
                    sis_account_id = parameters.Estudio?.Id
                }
            };
            var returnData = base.Put(url, param);
            var logData    = returnData as LogDto;

            if (logData != null)
            {
                var idLog = _logService.SaveLog(logData);
                result.Errors.Add(string.Format(CanvasApiStrings.ErrorApi, idLog));
                return(result);
            }
            result.Value = new AccountCanvasDto
            {
                Id            = returnData["id"],
                Name          = returnData["name"],
                SisId         = returnData["sis_account_id"],
                WorkflowState = returnData["workflow_state"],
                ParentId      = returnData["parent_account_id"]
            };
            return(result);
        }
Esempio n. 3
0
        public IHttpActionResult GenerarPeriodo(AccountSaveParameters param)
        {
            var result = _canvas.GenerarPeriodo(param);

            if (!result.HasErrors)
            {
                return(Ok(result.Value));
            }
            return(ResultWithMessages(result));
        }
Esempio n. 4
0
        public IHttpActionResult UpdateAccount([FromUri] int id, [FromBody] AccountSaveParameters param)
        {
            param.Id = id;
            var result = _canvas.UpdateAccount(param);

            if (!result.HasErrors)
            {
                return(Ok(result.Value));
            }
            return(ResultWithMessages(result));
        }