public void CreateIndicatorOk()
        {
            BaseCondition component = new Condition()
            {
                Id       = Guid.NewGuid(),
                ValueIzq = new StringValue {
                    Data = "hola"
                },
                ValueDer = new StringValue {
                    Data = "hola"
                },
                Operator = "="
            };
            Indicator indicator = new Indicator()
            {
                Color     = "red",
                Id        = Guid.NewGuid(),
                Condition = component
            };


            var mock = new Mock <IIndicatorLogic>(MockBehavior.Strict);

            mock.Setup(m => m.Create(It.IsAny <Indicator>())).Returns(indicator);

            var controller    = new IndicatorsController(mock.Object);
            var result        = controller.Post(IndicatorModel.ToModel(indicator));
            var createdResult = result as CreatedAtRouteResult;

            mock.VerifyAll();
        }
Ejemplo n.º 2
0
        public void DeleteArea()
        {
            List <User> managers = new List <User>();
            User        user     = new User
            {
                Id       = Guid.NewGuid(),
                Name     = "Santiago",
                LastName = "Larralde",
                UserName = "******",
                Password = "******",
                Admin    = false
            };

            managers.Add(user);
            IEnumerable <Indicator> indicators = new List <Indicator>();
            AreaModel area = new AreaModel()
            {
                Name             = "Area1",
                ConnectionString = "ConnectionString",
                Id         = Guid.NewGuid(),
                Indicators = IndicatorModel.ToModel(indicators).ToList(),
            };


            var mock = new Mock <IAreaLogic>(MockBehavior.Strict);

            mock.Setup(m => m.RemoveArea(It.IsAny <Area>()));

            var controller    = new AreasController(mock.Object);
            var result        = controller.Delete(area.Id, area);
            var createdResult = result as OkObjectResult;

            mock.VerifyAll();
        }
        /// <summary>
        /// TODO : To Get LoginHistory Details List...
        /// </summary>
        public async Task GetIntroductionList()
        {
            IntroductionList = new ObservableCollection <IntroductionModel>(IntroductionModel.GetIntroList());
            IndicatorList    = new ObservableCollection <IndicatorModel>();
            var indicatorList = new ObservableCollection <IndicatorModel>();
            int first         = 0;

            foreach (var item in IntroductionList)
            {
                IndicatorModel objIndicator = new IndicatorModel();
                if (first == 0)
                {
                    objIndicator.IsCurrent    = true;
                    objIndicator.IsNotCurrent = false;
                    first = 1;
                }
                else
                {
                    objIndicator.IsCurrent    = false;
                    objIndicator.IsNotCurrent = true;
                }
                objIndicator.Id = item.ID.ToString();
                indicatorList.Add(objIndicator);
            }
            IndicatorList = indicatorList;
        }
        public void DeleteIndicator()
        {
            BaseCondition component = new Condition()
            {
                Id       = Guid.NewGuid(),
                ValueIzq = new StringValue {
                    Data = "hola"
                },
                ValueDer = new StringValue {
                    Data = "hola"
                },
                Operator = "="
            };
            Indicator indicator = new Indicator()
            {
                Color     = "red",
                Id        = Guid.NewGuid(),
                Condition = component
            };


            var mock = new Mock <IIndicatorLogic>(MockBehavior.Strict);

            mock.Setup(m => m.Remove(It.IsAny <Indicator>()));

            var controller = new IndicatorsController(mock.Object);
            var result     = controller.Delete(indicator.Id, IndicatorModel.ToModel(indicator));

            mock.VerifyAll();
        }
Ejemplo n.º 5
0
        private void AddIndicatorsToTable(UserEntity user, PersonalDataSettings personalData)
        {
            IndicatorModel idicatorsModel = new IndicatorModel {
                IdUser     = user.Id,
                Weight     = personalData.Weight,
                Height     = personalData.Height,
                ChangeDate = DateTime.Now
            };

            _repository.Indicator.InsertIndicatorsIntoTable(idicatorsModel);
        }
Ejemplo n.º 6
0
 public IActionResult Get(Guid id)
 {
     try
     {
         var indicator = indicatorLogic.Get(id);
         return(Ok(IndicatorModel.ToModel(indicator)));
     }
     catch (BusinessLogicInterfaceException e)
     {
         return(NotFound(e.Message));
     }
 }
Ejemplo n.º 7
0
 public IActionResult Get()
 {
     try
     {
         IEnumerable <Indicator> indicatros = indicatorLogic.GetAll();
         return(Ok(IndicatorModel.ToModel(indicatros)));
     }
     catch (BusinessLogicInterfaceException e)
     {
         return(BadRequest(e.Message));
     }
 }
Ejemplo n.º 8
0
 public IActionResult GetIndicators(Guid id)
 {
     try
     {
         IEnumerable <Indicator> indicators = areaLogic.GetIndicators(id);
         return(Ok(IndicatorModel.ToModel(indicators)));
     }
     catch (BusinessLogicInterfaceException e)
     {
         return(NotFound(e.Message));
     }
 }
Ejemplo n.º 9
0
 public IActionResult Put(Guid id, [FromBody] IndicatorModel model)
 {
     try
     {
         model.Id = id;
         Indicator indicatorUpdated = indicatorLogic.Update(IndicatorModel.ToEntity(model));
         return(CreatedAtRoute("GetIndicator", new { id = indicatorUpdated.Id }, IndicatorModel.ToModel(indicatorUpdated)));
     }
     catch (BusinessLogicInterfaceException e)
     {
         return(BadRequest(e.Message));
     }
 }
        public async Task InsertIndicatorsIntoTable(IndicatorModel model)
        {
            var table = await _tableStorage.GetTableReference(_indicatorsTable);

            var entity = new IndicatorEntity()
            {
                PartitionKey        = Guid.NewGuid().ToString(),
                RowKey              = new Guid().ToString(),
                IndicatorsModelData = model
            };

            var tableOperation = TableOperation.InsertOrMerge(entity);
            await table.ExecuteAsync(tableOperation);
        }
Ejemplo n.º 11
0
        public IActionResult Post([FromBody] IndicatorModel model)
        {
            try
            {
                Indicator indicator        = model.ToEntity();
                var       indicatorCreated = indicatorLogic.Create(indicator);

                return(CreatedAtRoute("GetIndicator", new { id = indicatorCreated.Id }, IndicatorModel.ToModel(indicator)));
            }
            catch (BusinessLogicInterfaceException e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 12
0
        public void UpdateIndicator(IndicatorModel indicatorModel)
        {
            Models.DBObjects.Indicatori existingIndicator = dbContext.Indicatoris.FirstOrDefault(x => x.IdIndicator == indicatorModel.IdIndicator);

            if (existingIndicator != null)
            {
                existingIndicator.IdIndicator       = indicatorModel.IdIndicator;
                existingIndicator.Denumire          = indicatorModel.Denumire;
                existingIndicator.Descriere         = indicatorModel.Descriere;
                existingIndicator.Formula_de_calcul = indicatorModel.Formula_de_calcul;

                dbContext.SubmitChanges();
            }
        }
Ejemplo n.º 13
0
        private IndicatorModel MapDbObjectToModel(Models.DBObjects.Indicatori dbIndicator)
        {
            IndicatorModel indicatorModel = new IndicatorModel();

            if (dbIndicator != null)
            {
                indicatorModel.IdIndicator       = dbIndicator.IdIndicator;
                indicatorModel.Denumire          = dbIndicator.Denumire;
                indicatorModel.Descriere         = dbIndicator.Descriere;
                indicatorModel.Formula_de_calcul = dbIndicator.Formula_de_calcul;
                return(indicatorModel);
            }
            return(null);
        }
Ejemplo n.º 14
0
        private Models.DBObjects.Indicatori MapModelToDbObject(IndicatorModel indicatorModel)
        {
            Models.DBObjects.Indicatori dbIndicatorModel = new Models.DBObjects.Indicatori();

            if (indicatorModel != null)
            {
                dbIndicatorModel.IdIndicator       = indicatorModel.IdIndicator;
                dbIndicatorModel.Denumire          = indicatorModel.Denumire;
                dbIndicatorModel.Descriere         = indicatorModel.Descriere;
                dbIndicatorModel.Formula_de_calcul = indicatorModel.Formula_de_calcul;

                return(dbIndicatorModel);
            }
            return(null);
        }
Ejemplo n.º 15
0
        public IActionResult AddIndicator(Guid id, [FromBody] IndicatorModel model)
        {
            try
            {
                Indicator indicator = model.ToEntity();
                Area      area      = areaLogic.Get(id);
                indicator.Area = area;

                var indicatorCreated = indicatorLogic.Create(indicator);
                areaLogic.AddIndicator(id, indicatorCreated.Id);
                return(NoContent());
            }
            catch (BusinessLogicInterfaceException e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 16
0
        public IActionResult Post(int id, [FromBody] IndicatorModel model)
        {
            try
            {
                var indicator = IndicatorModel.ToEntity(model);
                indicator.Area = id;
                var toReturn            = indicatorLogic.AddIndicator(indicator);
                List <UserIndicator> ui = new List <UserIndicator>();

                return(Ok("Se agregó el area " + indicator.Name + " con el ID " + toReturn.ID + " al area "));
            }
            catch (AlreadyExistsException) { return(BadRequest("No es posible agregar un area ya existente")); }
            catch (NullException) { return(BadRequest("No es posible agregar un area nula")); }
            catch (NullReferenceException) { return(BadRequest("No es posible agregar un area nula")); }
            catch (NotValidException) { return(BadRequest("No es posible agregar un area no válida")); }
            catch (DataBaseLogicException) { return(BadRequest("Error en la conexión con la base de datos")); }
            catch (InvalidOperationLogicException) { return(BadRequest("Error en el sistema")); }
        }
Ejemplo n.º 17
0
        public IndicatorModel GetIndicatorValue(CandleModel currentCandle)
        {
            // ReSharper disable once UseObjectOrCollectionInitializer
            var result = new IndicatorModel();

            result.CandleFormat = CheckHammerCandleSticks(currentCandle);
            if (result.CandleFormat != CandleFormat.None)
            {
                return(result);
            }
            result.CandleFormat = CheckMarubozuCandleSticks(currentCandle);
            if (result.CandleFormat != CandleFormat.None)
            {
                return(result);
            }

            return(result);
        }
Ejemplo n.º 18
0
        public void GetAllAreas()
        {
            List <User> managers = new List <User>();
            User        user     = new User
            {
                Id       = Guid.NewGuid(),
                Name     = "Santiago",
                LastName = "Larralde",
                UserName = "******",
                Password = "******",
                Admin    = false
            };

            managers.Add(user);
            IEnumerable <Indicator> indicators = new List <Indicator>();
            AreaModel area = new AreaModel()
            {
                Name             = "Area1",
                ConnectionString = "ConnectionString",
                Id         = Guid.NewGuid(),
                Indicators = IndicatorModel.ToModel(indicators).ToList(),
            };


            List <Area> areas = new List <Area>();

            areas.Add(AreaModel.ToEntity(area));

            var mock = new Mock <IAreaLogic>(MockBehavior.Strict);

            mock.Setup(m => m.GetAll()).Returns(areas);

            var controller = new AreasController(mock.Object);
            var result     = controller.Get();

            var createdResult = result as OkObjectResult;
            var models        = createdResult.Value as IEnumerable <AreaModel>;

            mock.VerifyAll();

            Assert.AreEqual(areas[0].Name, models.ToList <AreaModel>()[0].Name);
        }
Ejemplo n.º 19
0
        public void CreateAreaOk()
        {
            IEnumerable <Indicator> indicators = new List <Indicator>();
            AreaModel area = new AreaModel()
            {
                Name             = "Area1",
                ConnectionString = "ConnectionString",
                Id         = Guid.NewGuid(),
                Indicators = IndicatorModel.ToModel(indicators).ToList(),
            };

            var mock = new Mock <IAreaLogic>(MockBehavior.Strict);

            mock.Setup(m => m.CreateArea(It.IsAny <Area>())).Returns(area.ToEntity);

            var controller    = new AreasController(mock.Object);
            var result        = controller.Post(area);
            var createdResult = result as CreatedAtRouteResult;

            mock.VerifyAll();
        }
        private Indicator IndicatorFromModel(Indicator indicator, IndicatorModel model)
        {
            if (model.Name != null)
            {
                indicator.Name = model.Name;
            }
            if (model.Green != null)
            {
                indicator.Green = model.Green;
            }
            if (model.Red != null)
            {
                indicator.Red = model.Red;
            }
            if (model.Yellow != null)
            {
                indicator.Yellow = model.Yellow;
            }

            return(indicator);
        }
Ejemplo n.º 21
0
 public void InsertIndicator(IndicatorModel indicatorModel)
 {
     indicatorModel.IdIndicator = Guid.NewGuid();
     dbContext.Indicatoris.InsertOnSubmit(MapModelToDbObject(indicatorModel));
     dbContext.SubmitChanges();
 }
Ejemplo n.º 22
0
 public static void SaveIndicators(IndicatorModel indicator)
 {
 }