public void Save(ReportGroup entity)
        {
            ValidationResultInfo vri = Validate(entity);
            if (!vri.IsValid)
                throw new DomainValidationException(vri, "ReportGroups  Details not Valid");
            DateTime date = DateTime.Now;
            ReportGroup tbl = _context.ReportGroups.FirstOrDefault(s => s.Id == entity.Id);
            if (tbl == null)
            {
                tbl = new ReportGroup();
                tbl.CreatedOn = date;
                tbl.IsActive = true;
                tbl.Id = entity.Id;
                _context.ReportGroups.Add(tbl);
            }
            tbl.Name = entity.Name;

            tbl.Description = entity.Description;
            tbl.ClientId = entity.ClientId;
            tbl.UpdatedOn = date;
            _context.SaveChanges();
        }
Esempio n. 2
0
        public BasicResponse Save(ReportGroupDTO dto)
        {
            var response = new BasicResponse();
            try
            {
                var entity = new ReportGroup
                {
                    Description = dto.Description,
                    Id = dto.Id,
                    Name = dto.Name,
                    ClientId  =dto.ClientId,
                    IsActive = true,
                };
                _reportGroupRepository.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;
        }
 public ValidationResultInfo Validate(ReportGroup itemToValidate)
 {
     return itemToValidate.BasicValidation();
 }
Esempio n. 4
0
 private ReportGroupDTO Map(ReportGroup entity)
 {
     if (entity == null)
         return null;
     var dto = new ReportGroupDTO
     {
         Description = entity.Description,
         ClientId = entity.ClientId,
         ClientName = entity.Client.Name,
         Id = entity.Id,
         IsActive = entity.IsActive,
         Name = entity.Name,
     };
     return dto;
 }