Exemplo n.º 1
0
        public void Delete(string value)
        {
            var dataDelete = new PortfolioDataModel();

            dataDelete.PortfolioId = int.Parse(value);
            PortfolioDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
Exemplo n.º 2
0
        public static int Create(PortfolioDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("Portfolio.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
Exemplo n.º 3
0
        public static string Save(PortfolioDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";


            switch (action)
            {
            case "Create":
                sql += "dbo.PortfolioInsert  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.PortfolioUpdate  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, PortfolioDataModel.DataColumns.PortfolioId);
            sql = sql + ", " + ToSQLParameter(data, PortfolioDataModel.DataColumns.FundId);
            sql = sql + ", " + ToSQLParameter(data, PortfolioDataModel.DataColumns.Name);
            sql = sql + ", " + ToSQLParameter(data, PortfolioDataModel.DataColumns.Description);
            sql = sql + ", " + ToSQLParameter(data, PortfolioDataModel.DataColumns.SortOrder);

            return(sql);
        }
Exemplo n.º 4
0
        private PortfolioViewModel GetViewModel(PortfolioDataModel dataModel)
        {
            var viewModel = new PortfolioViewModel()
            {
                Id                  = dataModel.Id,
                FirstName           = dataModel.FirstName,
                LastName            = dataModel.LastName,
                PhoneNumber         = dataModel.PhoneNumber,
                Email               = dataModel.Email,
                Age                 = dataModel.Age,
                EducationHighSchool = dataModel.EducationHighSchool,
                EducationCollege    = dataModel.EducationCollege,
                Experience          = dataModel.Experience,
                ExperienceYears     = dataModel.ExperienceYears,
                AboutMe             = dataModel.AboutMe,
                Services            = dataModel.Services,
                Facebook            = dataModel.Facebook,
                Twitter             = dataModel.Twitter,
            };


            Image img  = Image.FromFile(dataModel.ImageLocation);
            var   barr = ImageToByteArray(img);

            viewModel.Image = Convert.ToBase64String(barr);

            return(viewModel);
        }
Exemplo n.º 5
0
        public PortfolioDataModel GetById(string value)
        {
            var dataQuery = new PortfolioDataModel();

            dataQuery.PortfolioId = int.Parse(value);

            var result = PortfolioDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1);

            return(result[0]);
        }
Exemplo n.º 6
0
        public static bool DoesExist(PortfolioDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new PortfolioDataModel();

            doesExistRequest.ApplicationId = data.ApplicationId;
            doesExistRequest.FundId        = data.FundId;
            doesExistRequest.Name          = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
Exemplo n.º 7
0
        public void ShouldSaveDataModelToMongoLab()
        {
            // Arrange
            var portfolioDataModel = new PortfolioDataModel();

            _mongoDbProvider.Update <PortfolioDataModel>("portfolio", portfolioDataModel).Returns(portfolioDataModel);

            // Act
            var result = _repositoryUnderTest.Save(portfolioDataModel);

            // Assert
            Assert.That(result, Is.EqualTo(portfolioDataModel));
        }
Exemplo n.º 8
0
        public async Task <PortfolioDataList> GetPortfilo()
        {
            PortfolioDataList result = new PortfolioDataList();

            PortfolioDataModel data = new PortfolioDataModel()
            {
                ImageURL = "img/portfolio/cabin.png",
                Title    = "Log Cabin",
                Summary  = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam."
            };

            result.Portfolios.Add(data);
            data = new PortfolioDataModel()
            {
                ImageURL = "img/portfolio/cake.png",
                Title    = "Cakse",
                Summary  = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam."
            };
            result.Portfolios.Add(data);
            data = new PortfolioDataModel()
            {
                ImageURL = "img/portfolio/circus.png",
                Title    = "Circus",
                Summary  = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam."
            };
            result.Portfolios.Add(data);
            data = new PortfolioDataModel()
            {
                ImageURL = "img/portfolio/game.png",
                Title    = "Game",
                Summary  = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam."
            };
            result.Portfolios.Add(data);
            data = new PortfolioDataModel()
            {
                ImageURL = "img/portfolio/safe.png",
                Title    = "Safe",
                Summary  = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam."
            };
            result.Portfolios.Add(data);
            data = new PortfolioDataModel()
            {
                ImageURL = "img/portfolio/submarine.png",
                Title    = "Submarine",
                Summary  = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia neque assumenda ipsam nihil, molestias magnam, recusandae quos quis inventore quisquam velit asperiores, vitae? Reprehenderit soluta, eos quod consequuntur itaque. Nam."
            };
            result.Portfolios.Add(data);
            await Task.CompletedTask;

            return(result);
        }
Exemplo n.º 9
0
        public static void Delete(PortfolioDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.PortfolioDelete ";

            var parameters =
                new
            {
                AuditId       = requestProfile.AuditId
                , PortfolioId = data.PortfolioId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
Exemplo n.º 10
0
        //public

        public void UploadPortfolio(PortfolioBindingModel model, string Creator, string imageLocation)
        {
            try
            {
                PortfolioDataModel dataModel = new PortfolioDataModel
                {
                    ImageLocation       = imageLocation,
                    FirstName           = model.FirstName,
                    LastName            = model.LastName,
                    PhoneNumber         = model.PhoneNumber,
                    Email               = Creator,
                    Age                 = model.Age,
                    EducationHighSchool = model.EducationHighSchool,
                    EducationCollege    = model.EducationCollege,
                    Experience          = model.Experience,
                    ExperienceYears     = model.ExperienceYears,
                    AboutMe             = model.AboutMe,
                    Services            = model.Services,
                    Facebook            = model.FacebookAccount,
                    Twitter             = model.TwitterAccount,
                    CVLocation          = ""
                };
                using (var context = new PortfolioDatabase())
                {
                    if (context.Portfolio_table != null)
                    {
                        if (context.Portfolio_table
                            .FirstOrDefault(u => u.Email == Creator) == null)
                        {
                            context.Portfolio_table.Add(dataModel);
                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        context.Portfolio_table.Add(dataModel);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 11
0
        public void UpdatePortfolio(PortfolioBindingModel model, string Creator, string ImageLocation)
        {
            try
            {
                PortfolioDataModel dataModel = new PortfolioDataModel
                {
                    ImageLocation       = ImageLocation,
                    FirstName           = model.FirstName,
                    LastName            = model.LastName,
                    PhoneNumber         = model.PhoneNumber,
                    Email               = Creator,
                    Age                 = model.Age,
                    EducationHighSchool = model.EducationHighSchool,
                    EducationCollege    = model.EducationCollege,
                    Experience          = model.Experience,
                    ExperienceYears     = model.ExperienceYears,
                    AboutMe             = model.AboutMe,
                    Services            = model.Services,
                    Facebook            = model.FacebookAccount,
                    Twitter             = model.TwitterAccount,
                    CVLocation          = ""
                };
                using (var context = new PortfolioDatabase())
                {
                    var result = context.Portfolio_table.FirstOrDefault(p => p.Email == Creator);

                    if (ImageLocation == "")
                    {
                        dataModel.ImageLocation = result.ImageLocation;
                    }

                    context.Portfolio_table.Remove(result);
                    context.Portfolio_table.Add(dataModel);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 12
0
        public void ShouldSetupPortfolio()
        {
            var          portfolioRepository = new PortfolioRepository(_mongoDbProvider);
            const string dataBaseDir         = "C:/dev/Phillip Buttrose/Guitars/Web/assets/projects";

            Console.WriteLine("MigratePortfolio - purge");

            portfolioRepository.Purge();

            foreach (var directory in Directory.GetDirectories(dataBaseDir))
            {
                Console.WriteLine(string.Format("MigratePortfolio - load {0}", directory));

                var jsonData       = File.ReadAllText(Path.Combine(directory, "data.json"));
                var portfolio      = JsonConvert.DeserializeObject <Portfolio>(jsonData);
                var adoutDataModel = new PortfolioDataModel
                {
                    _id         = new ObjectId(),
                    Category    = portfolio.Category,
                    Classes     = portfolio.Classes,
                    Client      = portfolio.Client,
                    Date        = portfolio.Date,
                    Description = portfolio.Description,
                    Ref         = portfolio.Id,
                    Register    = portfolio.Register,
                    Title       = portfolio.Title,
                    SubTitle    = portfolio.SubTitle,
                    Thumb       = portfolioRepository.UploadFiles(directory, new List <string> {
                        portfolio.Thumb
                    }).FirstOrDefault(),
                    Images = portfolioRepository.UploadFiles(directory, portfolio.Images)
                };

                Console.WriteLine(string.Format("MigratePortfolio - save {0}", directory));

                portfolioRepository.Save(adoutDataModel);
            }
        }
Exemplo n.º 13
0
        public IEnumerable <JObject> GetSourceEntityList(string value)
        {
            var sourceEntity = new JavaScriptSerializer().Deserialize <string>(value);
            var listResult   = new List <JObject>();

            if (sourceEntity == "Portfolio")
            {
                var dataQuery   = new PortfolioDataModel();
                var entityItems = PortfolioDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

                foreach (var obj in entityItems)
                {
                    var jObject = new JObject();

                    jObject["Text"]      = obj.Name;
                    jObject["EntityKey"] = obj.PortfolioId;

                    listResult.Add(jObject);
                }
            }
            else if (sourceEntity == "CustodianAccount")
            {
                var dataQuery   = new CustodianAccountDataModel();
                var entityItems = CustodianAccountDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

                foreach (var obj in entityItems)
                {
                    var jObject = new JObject();

                    jObject["Text"]      = obj.Name;
                    jObject["EntityKey"] = obj.CustodianAccountId;

                    listResult.Add(jObject);
                }
            }

            return(listResult);
        }
Exemplo n.º 14
0
        public void ShouldRetrieveDataModelFromMongoLab()
        {
            // Arrange
            var newGuid = Guid.NewGuid().ToString().ToUpper();
            var query   = new QueryDocument {
                { "Ref", new BsonDocument {
                      { "$eq", newGuid }
                  } }
            };
            var portfolioDataModel = new PortfolioDataModel();

            _mongoDbProvider.Get <PortfolioDataModel>("portfolio", query).Returns(portfolioDataModel);

            // Act
            var result = _repositoryUnderTest.Get(new QueryDocument {
                { "Ref", new BsonDocument {
                      { "$eq", newGuid }
                  } }
            });

            // Assert
            Assert.That(result, Is.EqualTo(portfolioDataModel));
        }
Exemplo n.º 15
0
        public static List <PortfolioDataModel> GetEntityDetails(PortfolioDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.PortfolioSearch ";

            var parameters =
                new
            {
                AuditId           = requestProfile.AuditId
                , ApplicationId   = requestProfile.ApplicationId
                , ReturnAuditInfo = returnAuditInfo
                , PortfolioId     = dataQuery.PortfolioId
                , FundId          = dataQuery.FundId
                , Name            = dataQuery.Name
            };

            List <PortfolioDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <PortfolioDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
Exemplo n.º 16
0
        public static DataTable Search(PortfolioDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }
Exemplo n.º 17
0
        public static void Update(PortfolioDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("Portfolio.Update", sql, DataStoreKey);
        }
Exemplo n.º 18
0
        public static string ToSQLParameter(PortfolioDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case PortfolioDataModel.DataColumns.PortfolioId:
                if (data.PortfolioId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, PortfolioDataModel.DataColumns.PortfolioId, data.PortfolioId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PortfolioDataModel.DataColumns.PortfolioId);
                }
                break;

            case PortfolioDataModel.DataColumns.FundId:
                if (data.FundId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, PortfolioDataModel.DataColumns.FundId, data.FundId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PortfolioDataModel.DataColumns.FundId);
                }
                break;

            case PortfolioDataModel.DataColumns.Fund:
                if (!string.IsNullOrEmpty(data.Fund))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, PortfolioDataModel.DataColumns.Fund, data.Fund);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PortfolioDataModel.DataColumns.Fund);
                }
                break;

            case PortfolioDataModel.DataColumns.Name:
                if (!string.IsNullOrEmpty(data.Name))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, PortfolioDataModel.DataColumns.Name, data.Name);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PortfolioDataModel.DataColumns.Name);
                }
                break;

            case PortfolioDataModel.DataColumns.Description:
                if (!string.IsNullOrEmpty(data.Description))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, PortfolioDataModel.DataColumns.Description, data.Description);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PortfolioDataModel.DataColumns.Description);
                }
                break;

            case PortfolioDataModel.DataColumns.SortOrder:
                if (data.SortOrder != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, PortfolioDataModel.DataColumns.SortOrder, data.SortOrder);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, PortfolioDataModel.DataColumns.SortOrder);
                }
                break;


            default:
                returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }