Beispiel #1
0
        public async Task <IActionResult> AddNews(int condominiumId, [FromHeader] string Authorization, [FromBody] RequestPoll request)
        {
            try
            {
                var admin = await _administratorService.AuthToken(Authorization);

                if (admin == null)
                {
                    UnauthorizedResponse();
                    return(new ObjectResult(response));
                }

                var poll = new Poll()
                {
                    AdministratorId = admin.AdministratorId,
                    CondominiumId   = condominiumId,
                    Description     = request.Description,
                    EndDate         = request.EndDate,
                    StartDate       = request.StartDate,
                    IsDelete        = false,
                    Title           = request.Title
                };
                var pollSaved = await _pollService.Insert(poll);

                OkResponse(pollSaved);
                return(new ObjectResult(response));
            }
            catch (Exception e)
            {
                InternalServerErrorResponse(e.Message);
                return(new ObjectResult(response));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> AddCondominium([FromHeader] string Authorization, [FromBody] Condominium request)
        {
            try
            {
                var admin = await _administratorService.AuthToken(Authorization);

                if (admin == null)
                {
                    UnauthorizedResponse();
                    return(new ObjectResult(response));
                }

                request.AdministratorId = admin.AdministratorId;
                var condominiumSaved = await _condominiumService.Insert(request);

                OkResponse(condominiumSaved);
                return(new ObjectResult(response));
            }
            catch (Exception e)
            {
                InternalServerErrorResponse(e.Message);
                return(new ObjectResult(response));
            }
        }
Beispiel #3
0
        public async Task <IActionResult> PostBillByDepartment(int condominiumId, int departmentId, [FromHeader] string Authorization, [FromBody] RequestBill request)
        {
            try
            {
                var admin = await _administratorService.AuthToken(Authorization);

                if (admin == null)
                {
                    UnauthorizedResponse();
                    return(new ObjectResult(response));
                }

                var bill = new Bill()
                {
                    AdministratorId   = admin.AdministratorId,
                    Amount            = request.Amount,
                    CondominiumId     = condominiumId,
                    DepartmentId      = departmentId,
                    Description       = request.Description,
                    EndDate           = request.EndDate,
                    StartDate         = request.StartDate,
                    IsDelete          = false,
                    Name              = request.Name,
                    PaymentCategoryId = request.PaymentCategoryId
                };
                var billSaved = await _billService.Insert(bill);

                OkResponse(billSaved);
                return(new ObjectResult(response));
            }
            catch (Exception e)
            {
                InternalServerErrorResponse(e.Message);
                return(new ObjectResult(response));
            }
        }