Ejemplo n.º 1
0
 public void NodeTypeDtoConstructorTest()
 {
     int id = 0; // TODO: Initialize to an appropriate value
     string typeName = string.Empty; // TODO: Initialize to an appropriate value
     NodeTypeDto target = new NodeTypeDto(id, typeName);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Delete specified NodeType from database
        /// </summary>
        /// <param name="user">dto NodeType</param>
        public void DeleteNodeType(NodeTypeDto 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.NodeTypes);

                //Find NodeType which have to be deleted.
                NodeType existingNodeType = dbContext.NodeTypes.Single(nt => nt.Id == dto.Id);

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

                    //Saves chages.
                    dbContext.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
        }
Ejemplo n.º 3
0
 public void IdTest()
 {
     NodeTypeDto target = new NodeTypeDto(); // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     target.Id = expected;
     actual = target.Id;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Ejemplo n.º 4
0
 public void TypeNameTest()
 {
     NodeTypeDto target = new NodeTypeDto(); // TODO: Initialize to an appropriate value
     string expected = string.Empty; // TODO: Initialize to an appropriate value
     string actual;
     target.TypeName = expected;
     actual = target.TypeName;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Ejemplo n.º 5
0
 public void NodeTypeDtoConstructorTest1()
 {
     NodeTypeDto target = new NodeTypeDto();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns list of all Node Types from database.
        /// </summary>
        /// <returns>List list of NodeTypeDto's</returns>
        public List<NodeTypeDto> GetAllNodeTypes()
        {
            //Instantiate list of dto node Types which has been returned.
            List<NodeTypeDto> listDto = new List<NodeTypeDto>();
            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.NodeTypes);

                //list of Node types from entities
                List<NodeType> list = dbContext.NodeTypes.OrderBy(nt => nt.Id).ToList();

                //filling the list
                foreach (NodeType nt in list)
                {
                    NodeTypeDto nodeTypeDto = new NodeTypeDto(nt.Id, nt.TypeName);
                    listDto.Add(nodeTypeDto);
                }
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
            //returns list of all node types as list of dtoes.
            return listDto;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Update NodeType in database
        /// </summary>
        /// <param name="dto">dto of NodeType</param>
        public void UpdateNodeType(NodeTypeDto 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.NodeTypes);

                //Find NodeType which have to be updated.
                NodeType existingNodeType = dbContext.NodeTypes.Single(nt => nt.Id == dto.Id);

                //If required NodeType doesn't exists, throw exception.
                if (existingNodeType == null)
                {
                    throw new Exception("Node Type does not exist");
                }
                //else prepare all data for storing to database
                else
                {
                    existingNodeType.Id = dto.Id;
                    existingNodeType.TypeName = dto.TypeName;
                }

                //Save changes
                dbContext.SaveChanges();
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Insert specified NodeType in database
        /// </summary>
        /// <param name="dto">dto data for NodeType</param>
        public void InsertNodeType(NodeTypeDto 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.NodeTypes);
                NodeType nt = new NodeType();

                nt.Id = dto.Id;
                nt.TypeName = dto.TypeName;

                //Adds new NodeType details to context
                dbContext.NodeTypes.AddObject(nt);

                //saves changes.
                dbContext.SaveChanges();
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
        }