public BugTrackingResponse <BusinessObjects.Organization> Save(BusinessObjects.Organization org)
        {
            Logger.TraceMethodStart(ClassName, "Save");

            var response = new BugTrackingResponse <BusinessObjects.Organization>();

            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var validator = new OrganizationSpecification();
                        var result    = validator.Validate(org);
                        var failures  = result.Errors;

                        response.ValidationResult = result;

                        if (result.IsValid)
                        {
                            org.LastModified = DateTime.Now;
                            org.Active       = true;
                            var neworg = MapperAllLevels.Map <BusinessObjects.Organization, EntityModel.Organization>(org);
                            db.Organizations.Add(neworg);
                            db.SaveChanges();
                            transaction.Commit();
                        }

                        else
                        {
                            transaction.Rollback();
                            Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors);
                        }

                        return(response);
                    }



                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                        throw;
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "Save");
                    }
                }
            }
        }
        public async Task <IActionResult> GetOrganizations(
            string organizationIdentificationNumber,
            string organizationTradingName,
            long?partyRoleID,
            string fullName,
            [FromQuery] QueryOptions queryOptions,
            int?level = null,
            bool onlyActiveRecords = true
            )
        {
            var specification = new OrganizationSpecification(
                organizationIdentificationNumber,
                organizationTradingName,
                partyRoleID,
                level,
                onlyActiveRecords
                );

            return(Ok(await _mediator.Send(new GetOrganizationsQuery(specification, queryOptions))));
        }
Пример #3
0
 public GetOrganizationsQuery(OrganizationSpecification specification, QueryOptions queryOptions)
 {
     Specification = specification;
     QueryOptions  = queryOptions;
 }