/// <summary>
        /// Delete specified user systeminformation details from database
        /// </summary>
        /// <param name="user">dto User System Information details</param>
        public void DeleteUsersSystemInformationDetails(UserSystemInformationDto 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.UserSystemInformations);

                //Find user system information system information which have to bee updated.
                UserSystemInformation existingUsersSystemInformation = dbContext.UserSystemInformations.Single(usi => usi.UserId == dto.UserId);

                //If required user system infrormation doesn't exists, throw exception.
                if (existingUsersSystemInformation == null)
                {
                    throw new Exception("Users system information does not exist");
                }
                //else prepare all data for deleting from database
                else
                {
                    //Delete user system information details.
                    dbContext.DeleteObject(existingUsersSystemInformation);

                    //Saves chages.
                    dbContext.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                throw new Exception("UserDataMenagers: " + exception.Message);
            }
        }
 public void LastSuccessfullLogInTest()
 {
     UserSystemInformationDto target = new UserSystemInformationDto(); // TODO: Initialize to an appropriate value
     string expected = string.Empty; // TODO: Initialize to an appropriate value
     string actual;
     target.LastSuccessfullLogIn = expected;
     actual = target.LastSuccessfullLogIn;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void IdTest()
 {
     UserSystemInformationDto target = new UserSystemInformationDto(); // 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.");
 }
        /// <summary>
        /// Returns list of all users system information details from database.
        /// </summary>
        /// <returns>List list of userSystemInformationDto's</returns>
        public List<UserSystemInformationDto> GetAllUsersSystemInformationDetails()
        {
            //Instantiate list of dto users system information details which has been returned.
            List<UserSystemInformationDto> listDto = new List<UserSystemInformationDto>();
            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.UserSystemInformations);

                //list of users system information details from entities
                List<UserSystemInformation> list = dbContext.UserSystemInformations.OrderBy(usi => usi.UserId).ToList();

                //filling the list
                foreach (UserSystemInformation usi in list)
                {
                    UserSystemInformationDto userSystemInformationDto = new UserSystemInformationDto(usi.Id, usi.UserTypeId, usi.IsLoggedIn, usi.LastSuccessfullLogIn, usi.UserId);
                    listDto.Add(userSystemInformationDto);
                }
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
            //returns list of all users system information details as list of dtoes.
            return listDto;
        }
        /// <summary>
        /// Insert specified user system infromation details in database
        /// </summary>
        /// <param name="dto">dto data for user system information details</param>
        public void InsertUsersSystemInformationDetails(UserSystemInformationDto 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.UserSystemInformations);
                //New users system information details - setting data
                UserSystemInformation usi = new UserSystemInformation();
                usi.UserTypeId = dto.UserTypeId;
                usi.IsLoggedIn = dto.IsLoggedIn;
                usi.LastSuccessfullLogIn = dto.LastSuccessfullLogIn;
                usi.UserId = dto.UserId;

                //Adds new personal userdetails to context
                dbContext.UserSystemInformations.AddObject(usi);

                //saves changes.
                dbContext.SaveChanges();
            }
            catch (Exception exception)
            {
                throw new Exception("UserDataMenagers: " + exception.Message);
            }
        }
        /// <summary>
        /// Returns list of all users system information details from database.
        /// </summary>
        /// <returns>List list of userSystemInformationDto's</returns>
        public UserSystemInformationDto GetUserSystemInformationDetailsByUserId(int UserId)
        {
            UserSystemInformationDto userSystemInformationDto = null;
            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.UserSystemInformations);

                UserSystemInformation obje = dbContext.UserSystemInformations.Single(usi => usi.UserId == UserId);
                userSystemInformationDto = new UserSystemInformationDto(obje.Id, obje.UserTypeId, obje.IsLoggedIn, obje.LastSuccessfullLogIn, obje.UserId);
            }
            catch (Exception exception)
            {
                throw new Exception("SmartGridDataMenagers: " + exception.Message);
            }
            //returns users system information details dto.
            return userSystemInformationDto;
        }
 public void UserSystemInformationDtoConstructorTest1()
 {
     UserSystemInformationDto target = new UserSystemInformationDto();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public void UserSystemInformationDtoConstructorTest()
 {
     int id = 0; // TODO: Initialize to an appropriate value
     int userTypeId = 0; // TODO: Initialize to an appropriate value
     string isLoggedIn = string.Empty; // TODO: Initialize to an appropriate value
     string lastSuccessfullLogIn = string.Empty; // TODO: Initialize to an appropriate value
     int userId = 0; // TODO: Initialize to an appropriate value
     UserSystemInformationDto target = new UserSystemInformationDto(id, userTypeId, isLoggedIn, lastSuccessfullLogIn, userId);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }