/// <summary>
        /// Delete specified NodeReactiveLoad from database
        /// </summary>
        /// <param name="user">dto NodeReactiveLoad</param>
        public void DeleteNodeReactiveLoad(NodeReactiveLoadDto dto)
        {
            try
            {
                //Before any action, it must be updated because calls from contract uses
                //only one instance of BranchManager.
                dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.ReactiveLoads);

                //Find NodeReactiveLoad which have to be deleted.
                ReactiveLoad existingReactiveLoad = dbContext.ReactiveLoads.Single(rl => rl.Id == dto.Id);

                //If required NodeReactiveLoad doesn't exists, throw exception.
                if (existingReactiveLoad == null)
                {
                    throw new Exception("Node Reactive Load does not exist");
                }
                //else perform delete from database
                else
                {
                    //Delete branch.
                    dbContext.DeleteObject(existingReactiveLoad);

                    //Saves chages.
                    dbContext.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
        }
        /// <summary>
        /// Annull all values after server stop.
        /// </summary>
        /// <returns>String annulment info</returns>
        public String AnnullValues()
        {
            String annulmentInfo = null;
            //Annullment list of dto node reactive loads which has been returned.
            List<NodeReactiveLoadDto> listDto = new List<NodeReactiveLoadDto>();
            try
            {
                //Before any action, it must be updated because calls from contract uses
                //only one instance of UserManager.
                dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.ReactiveLoads);

                //list of reactive loads from entities
                List<ReactiveLoad> list = dbContext.ReactiveLoads.OrderBy(rl => rl.Id).ToList();

                //filling the list
                foreach (ReactiveLoad rl in list)
                {
                    NodeReactiveLoadDto nodeReactiveLoadDto = new NodeReactiveLoadDto(rl.Id, rl.InitialReactiveLoad, rl.CurrentReactiveLoad, rl.MinimalReactiveLoad, rl.MaximalReactiveLoad);
                    nodeReactiveLoadDto.CurrentReactiveLoad = 0;
                    UpdateNodeReactiveLoad(nodeReactiveLoadDto);
                    annulmentInfo = annulmentInfo + "\t- Current node reactive load at id: " + nodeReactiveLoadDto.Id + "\t-> Annulled.\r\n";
                }
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
            //returns String which shows initialization details
            return annulmentInfo;
        }
 public void InitialReactiveLoadTest()
 {
     NodeReactiveLoadDto target = new NodeReactiveLoadDto(); // TODO: Initialize to an appropriate value
     double expected = 0F; // TODO: Initialize to an appropriate value
     double actual;
     target.InitialReactiveLoad = expected;
     actual = target.InitialReactiveLoad;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
        /// <summary>
        /// Update NodeReactiveLoad in database
        /// </summary>
        /// <param name="dto">dto of NodeReactiveLoad</param>
        public void UpdateNodeReactiveLoad(NodeReactiveLoadDto dto)
        {
            try
            {
                //Before any action, it must be updated because calls from contract uses
                //only one instance of UserManager.
                dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.ReactiveLoads);

                //Find NodeReactiveLoad which have to be updated.
                ReactiveLoad existingReactiveLoad = dbContext.ReactiveLoads.Single(rl => rl.Id == dto.Id);

                //If required NodeReactiveLoad doesn't exists, throw exception.
                if (existingReactiveLoad == null)
                {
                    throw new Exception("Node Reactive load does not exist");
                }
                //else prepare all data for storing to database
                else
                {
                    existingReactiveLoad.Id = dto.Id;
                    existingReactiveLoad.InitialReactiveLoad = dto.InitialReactiveLoad;
                    existingReactiveLoad.CurrentReactiveLoad = dto.CurrentReactiveLoad;
                    existingReactiveLoad.MinimalReactiveLoad = dto.MinimalReactiveLoad;
                    existingReactiveLoad.MaximalReactiveLoad = dto.MaximalReactiveLoad;
                }

                //Save changes
                dbContext.SaveChanges();
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
        }
        /// <summary>
        /// Insert specified NodeReactiveLoad in database
        /// </summary>
        /// <param name="dto">dto data for NodeReactiveLoad</param>
        public void InsertNodeReactiveLoad(NodeReactiveLoadDto dto)
        {
            try
            {
                //Before any action, it must be updated because calls from contract uses
                //only one instance of UserManager.
                dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.ReactiveLoads);
                ReactiveLoad rl = new ReactiveLoad();

                rl.Id = dto.Id;
                rl.InitialReactiveLoad = dto.InitialReactiveLoad;
                rl.CurrentReactiveLoad = dto.CurrentReactiveLoad;
                rl.MinimalReactiveLoad = dto.MinimalReactiveLoad;
                rl.MaximalReactiveLoad = dto.MaximalReactiveLoad;

                //Adds new NodeReactiveLoad details to context
                dbContext.ReactiveLoads.AddObject(rl);

                //saves changes.
                dbContext.SaveChanges();
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
        }
        /// <summary>
        /// Returns list of all node Reactive loads from database.
        /// </summary>
        /// <returns>List list of NodeReactiveLoadDto's</returns>
        public List<NodeReactiveLoadDto> GetAllNodeReactiveLoads()
        {
            //Instantiate list of dto node Reactive loads which has been returned.
            List<NodeReactiveLoadDto> listDto = new List<NodeReactiveLoadDto>();
            try
            {
                //Before any action, it must be updated because calls from contract uses
                //only one instance of UserManager.
                dbContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, dbContext.ReactiveLoads);

                //list of Reactive loads from entities
                List<ReactiveLoad> list = dbContext.ReactiveLoads.OrderBy(rl => rl.Id).ToList();

                //filling the list
                foreach (ReactiveLoad rl in list)
                {
                    NodeReactiveLoadDto nodeReactiveLoadDto = new NodeReactiveLoadDto(rl.Id, rl.InitialReactiveLoad, rl.CurrentReactiveLoad, rl.MinimalReactiveLoad, rl.MaximalReactiveLoad);
                    listDto.Add(nodeReactiveLoadDto);
                }
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
            //returns list of all node Reactive loads as list of dtoes.
            return listDto;
        }
 public void NodeReactiveLoadDtoConstructorTest1()
 {
     NodeReactiveLoadDto target = new NodeReactiveLoadDto();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public void NodeReactiveLoadDtoConstructorTest()
 {
     int id = 0; // TODO: Initialize to an appropriate value
     double initialReactiveLoad = 0F; // TODO: Initialize to an appropriate value
     double currentReactiveLoad = 0F; // TODO: Initialize to an appropriate value
     double minimalReactiveLoad = 0F; // TODO: Initialize to an appropriate value
     double maximalReactiveLoad = 0F; // TODO: Initialize to an appropriate value
     NodeReactiveLoadDto target = new NodeReactiveLoadDto(id, initialReactiveLoad, currentReactiveLoad, minimalReactiveLoad, maximalReactiveLoad);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }