コード例 #1
0
        public void Save(ReportGroupItem entity)
        {
            ValidationResultInfo vri = Validate(entity);
            if (!vri.IsValid)
                throw new DomainValidationException(vri, "ReportGroupItem  Details not Valid");
            DateTime date = DateTime.Now;
            ReportGroupItem tbl = _context.ReportGroupItems.FirstOrDefault(s => s.Id == entity.Id);
            if (tbl == null)
            {
                tbl = new ReportGroupItem();
                tbl.CreatedOn = date;
                tbl.IsActive = true;
                tbl.Id = entity.Id;
                _context.ReportGroupItems.Add(tbl);
            }
            tbl.Name = entity.Name;

            tbl.Description = entity.Description;
            tbl.GroupId = entity.GroupId;
            tbl.ReportOrder = entity.ReportOrder;
            tbl.ReportUrl = entity.ReportUrl;

            tbl.UpdatedOn = date;
            _context.SaveChanges();
        }
コード例 #2
0
        public BasicResponse Save(ReportGroupItemDTO dto)
        {
            var response = new BasicResponse();
            try
            {
                var entity = new ReportGroupItem()
                {
                    Description = dto.Description,
                    Id = dto.Id,
                    Name = dto.Name,
                    GroupId  = dto.GroupId,
                    ReportOrder = dto.ReportOrder,
                    ReportUrl = dto.ReportUrl,
                    IsActive = true,
                };
                _reportGroupItemRepository.Save(entity);
                response.Status = true;
                response.Info = "Success";

            }

            catch (Exception ex)
            {
                response.Status = false;
                if (ex is DomainValidationException)
                {
                    var dex = ex as DomainValidationException;
                    response.Info = dex.FormatException();
                }
                else
                {
                    response.Status = false;
                    response.Info = ex.Message;
                }

            }
            return response;
        }
コード例 #3
0
 private ReportGroupItemDTO Map(ReportGroupItem entity)
 {
     if (entity == null)
         return null;
     var dto = new ReportGroupItemDTO
     {
         Description = entity.Description,
         GroupId = entity.GroupId,
         GroupName = entity.Group.Name,
         ReportOrder = entity.ReportOrder,
         ReportUrl = entity.ReportUrl,
         Id = entity.Id,
         IsActive = entity.IsActive,
         Name = entity.Name,
     };
     return dto;
 }
コード例 #4
0
 public ValidationResultInfo Validate(ReportGroupItem itemToValidate)
 {
     return itemToValidate.BasicValidation();
 }