示例#1
0
        public async Task <int> UpdateListing(DALListingModel dalListingModel)
        {
            var businessListing = ModelConverterService.ConvertTo(new BusinessListingModel(), dalListingModel);
            int returnValue     = await _listingRepository.UpdateListing(businessListing);

            return(returnValue);
        }
        public async Task <int> UpdateListing(DALListingModel dalListingModel)
        {
            var query = "dbo.EditParentListing";


            return(await _dataGateway.Execute(query,
                                              new
            {
                Title = dalListingModel.Title,
                Details = dalListingModel.Details,
                City = dalListingModel.City,
                State = dalListingModel.State,
                NumberOfParticipants = dalListingModel.NumberOfParticipants,
                InPersonOrRemote = dalListingModel.InPersonOrRemote
            },
                                              _connectionString.SqlConnectionString));

            ;
        }
        public async Task <int> CreateListing(DALListingModel dalListingModel)
        {
            string storedProcedure = "dbo.CreateListingParent";

            DynamicParameters p = new DynamicParameters();

            p.Add("Title", dalListingModel.Title);
            p.Add("Details", dalListingModel.Details);
            p.Add("City", dalListingModel.City);
            p.Add("State", dalListingModel.State);
            p.Add("NumberOfParticipants", dalListingModel.NumberOfParticipants);
            p.Add("InPersonOrRemote", dalListingModel.InPersonOrRemote);
            p.Add("UserAccountId", dalListingModel.UserAccountId);
            p.Add("Id", DbType.Int32, direction: ParameterDirection.Output);

            await _dataGateway.Execute(storedProcedure, p, _connectionString.SqlConnectionString);

            return(p.Get <int>("Id"));
        }
示例#4
0
        public async Task Init()
        {
            await TestCleaner.CleanDatabase();

            var numTestRows = 20;

            IDataGateway          dataGateway       = new SQLServerGateway();
            IConnectionStringData connectionString  = new ConnectionStringData();
            IListingRepository    listingRepository = new ListingRepository(dataGateway, connectionString);

            for (int i = 1; i <= numTestRows; ++i)
            {
                DALListingModel dalListingModel = new DALListingModel();
                dalListingModel.Id      = i;
                dalListingModel.Title   = "TestTitle" + i;
                dalListingModel.Details = "TestDetails" + i;
                dalListingModel.City    = "TestCity" + i;
                dalListingModel.State   = "TestState" + i;
                dalListingModel.NumberOfParticipants = 5;
                dalListingModel.InPersonOrRemote     = "TestInpersonOrRemote" + i;

                await listingRepository.CreateListing(dalListingModel);
            }
        }
        public async Task <int> CreateListing(BusinessListingModel businessListingmodel)
        {
            if (businessListingmodel is BusinessCollaborationModel)
            {
                // Step 1: Create businessListingModel
                BusinessCollaborationModel newBusinessCollaborationModel = (BusinessCollaborationModel)businessListingmodel;
                BusinessListingModel       newBusinessListingModel       = new BusinessListingModel();

                // Step 2: Access parent props of collaboration Model to the step 1 model
                newBusinessListingModel.Title   = newBusinessCollaborationModel.Title;
                newBusinessListingModel.Details = newBusinessCollaborationModel.Details;
                newBusinessListingModel.City    = newBusinessCollaborationModel.City;
                newBusinessListingModel.State   = newBusinessCollaborationModel.State;
                newBusinessListingModel.NumberOfParticipants = newBusinessCollaborationModel.NumberOfParticipants;
                newBusinessListingModel.InPersonOrRemote     = newBusinessCollaborationModel.InPersonOrRemote;
                newBusinessListingModel.UserAccountId        = newBusinessCollaborationModel.UserAccountId;


                DALListingModel       dALListingModel       = new DALListingModel();
                DALCollaborationModel dALCollaborationModel = new DALCollaborationModel();

                // Step 3 : Convert both originalBusinessListingModel and step 1 created model to DALListingModel and DALCollaboration model
                var dalListingModel       = ModelConverterService.ConvertTo(newBusinessListingModel, dALListingModel);
                var dalCollaborationModel = ModelConverterService.ConvertTo(newBusinessCollaborationModel, dALCollaborationModel);

                // Step 4 : Call ListingRepo pass in DalListing Model, call CollaborationRepo pass in CollaborationModel to both create Functions in the repo
                var result = await _listingRepository.CreateListing(dalListingModel);

                dalCollaborationModel.ListingId = result;

                await _collaborationRepository.CreateListing(dalCollaborationModel); //collaboration repo instead of listing repo

                return(result);
            }



            else if (businessListingmodel is BusinessRelationshipModel)
            {
                // Same steps as is BusinessCollaborationModel
                // Step 1: Create businessListingModel
                BusinessRelationshipModel newBusinessRelationshipModel = (BusinessRelationshipModel)businessListingmodel;
                BusinessListingModel      newBusinessListingModel      = new BusinessListingModel();

                // Step 2: Access parent props of collaboration Model to the step 1 model
                newBusinessListingModel.Title   = newBusinessRelationshipModel.Title;
                newBusinessListingModel.Details = newBusinessRelationshipModel.Details;
                newBusinessListingModel.City    = newBusinessRelationshipModel.City;
                newBusinessListingModel.State   = newBusinessRelationshipModel.State;
                newBusinessListingModel.NumberOfParticipants = newBusinessRelationshipModel.NumberOfParticipants;
                newBusinessListingModel.InPersonOrRemote     = newBusinessRelationshipModel.InPersonOrRemote;
                newBusinessListingModel.UserAccountId        = newBusinessRelationshipModel.UserAccountId;

                DALListingModel      dALListingModel      = new DALListingModel();
                DALRelationshipModel dALRelationshipModel = new DALRelationshipModel();

                //Step 3: Convert both originalBusinessListingModel and step 1 created model to DALListingModel and DALCollaboration model
                var dalListingModel      = ModelConverterService.ConvertTo(newBusinessListingModel, dALListingModel);
                var dalRelationshipModel = ModelConverterService.ConvertTo(newBusinessRelationshipModel, dALRelationshipModel);

                // Step 4 : Call ListingRepo pass in DalListing Model, call CollaborationRepo pass in CollaborationModel to both create Functions in the repo
                var result = await _listingRepository.CreateListing(dalListingModel);

                dalRelationshipModel.ListingId = result;

                await _relationshipRepository.CreateListing(dalRelationshipModel); //collaboration repo instead of listing repo

                return(result);
            }
            else if (businessListingmodel is BusinessDatingModel)
            {
                // Create ListingModel, RelationshipModel, DatingModel
                // Same steps but instead of 2 models to be created, i need to create 3
                BusinessRelationshipModel newBusinessRelationshipModel = (BusinessRelationshipModel)businessListingmodel;
                BusinessListingModel      newBusinessListingModel      = new BusinessListingModel();
                BusinessDatingModel       newBusinessDatingModel       = (BusinessDatingModel)businessListingmodel;

                newBusinessListingModel.Title   = newBusinessRelationshipModel.Title;
                newBusinessListingModel.Details = newBusinessRelationshipModel.Details;
                newBusinessListingModel.City    = newBusinessRelationshipModel.City;
                newBusinessListingModel.State   = newBusinessRelationshipModel.State;
                newBusinessListingModel.NumberOfParticipants = newBusinessRelationshipModel.NumberOfParticipants;
                newBusinessListingModel.InPersonOrRemote     = newBusinessRelationshipModel.InPersonOrRemote;
                newBusinessListingModel.UserAccountId        = newBusinessRelationshipModel.UserAccountId;


                DALListingModel      dALListingModel      = new DALListingModel();
                DALRelationshipModel dALRelationshipModel = new DALRelationshipModel();
            }
            else if (businessListingmodel is BusinessTeamModel)
            {
                BusinessTeamModel    newBusinessTeamModel    = (BusinessTeamModel)businessListingmodel;
                BusinessListingModel newBusinessListingModel = new BusinessListingModel();
                newBusinessListingModel.Title   = newBusinessTeamModel.Title;
                newBusinessListingModel.Details = newBusinessTeamModel.Details;
                newBusinessListingModel.City    = newBusinessTeamModel.City;
                newBusinessListingModel.State   = newBusinessTeamModel.State;
                newBusinessListingModel.NumberOfParticipants = newBusinessTeamModel.NumberOfParticipants;
                newBusinessListingModel.InPersonOrRemote     = newBusinessTeamModel.InPersonOrRemote;
                newBusinessListingModel.UserAccountId        = newBusinessTeamModel.UserAccountId;



                DALListingModel dALListingModel = new DALListingModel();
                DALTeamModel    dALTeamModel    = new DALTeamModel();

                var dalListingModel = ModelConverterService.ConvertTo(newBusinessListingModel, dALListingModel);
                var dalTeamModel    = ModelConverterService.ConvertTo(newBusinessTeamModel, dALTeamModel);

                var result = await _listingRepository.CreateListing(dalListingModel);

                dalTeamModel.ListingId = result;

                await _teamModelRepository.CreateListing(dalTeamModel); //collaboration repo instead of listing repo

                return(result);
            }

            return(0);
        }
示例#6
0
 public Task <int> UpdateListing(DALListingModel dalListingModel)
 {
     throw new NotImplementedException();
 }