Esempio n. 1
0
        public void CreateReportGroup(ReportGroupDto reportGroupDto)
        {
            var reportGroup = new ReportGroup(reportGroupDto.GroupName, reportGroupDto.DisplayName,
                                              reportGroupDto.Description, reportGroupDto.CreatedBy);

            this._reportGroupRepository.Add(reportGroup);
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateReportGroup([FromRoute] int id, [FromBody] ReportGroupDto entityDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != entityDto.Id)
            {
                return(BadRequest());
            }

            var entity = await _repository.GetByIdAsync(entityDto.Id);

            if (entity == null)
            {
                return(NotFound("Report does not exist"));
            }

            _mapper.Map(entityDto, entity);

            try
            {
                _repository.Update(entity);
                await _unitOfWork.SaveAsync();
            }

            catch (Exception)
            {
                throw new Exception("An unexpected error occured. Could not update.");
            }

            return(NoContent());
        }
Esempio n. 3
0
        public void UpdateReportGroup(ReportGroupDto reportGroupDto)
        {
            var reportGroup = this._reportGroupRepository.GetByKey(reportGroupDto.ID);

            if (reportGroup == null)
            {
                return;
            }

            reportGroup.UpdateGroupHeader(reportGroupDto.DisplayName, reportGroupDto.Description,
                                          reportGroupDto.UpdatedBy);
            this._reportGroupRepository.Update(reportGroup);
        }
 public ActionResult SetGroupItem(ReportGroupDto model, IEnumerable <Guid> profiles)
 {
     try
     {
         using (var service = ServiceLocator.Instance.Resolve <IReportGroupService>())
         {
             service.SetReportGroupItems(model.ID, profiles);
             return(Json(true));
         }
     }
     catch (Exception)
     {
         return(Json(false, "Set the report group items failure."));
     }
 }
 public ActionResult EditGroup(ReportGroupDto model)
 {
     model.UpdatedBy = this.LoginUser.Identity.Name;
     try
     {
         using (var service = ServiceLocator.Instance.Resolve <IReportGroupService>())
         {
             service.UpdateReportGroup(model);
             return(Json(true));
         }
     }
     catch (Exception)
     {
         return(Json(false, "Create the report group failure."));
     }
 }
Esempio n. 6
0
        public async Task <IActionResult> CreateReportGroup([FromBody] ReportGroupDto entityDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var entity = _mapper.Map <ReportGroup>(entityDto);

            try
            {
                _repository.Add(entity);
                await _unitOfWork.SaveAsync();

                var createdResult = CreatedAtAction("GetReportGroupById", new { id = entity.Id }, entity.Id);
                createdResult.StatusCode = 200;
                return(createdResult);
            }
            catch (Exception e)
            {
                throw new Exception("An unexpected error occured. Could not be added.", e);
            }
        }