Ejemplo n.º 1
0
 public void SetUp()
 {
     _accountInfoRepository = new AccountInfoRepository();
     _accountInfo1 = new AccountInfoDTO {AccountNumber = 3001, AccountName = "testkonto1", IsIncome = true, PartsReportCategory = 1, ResultReportCategory = 1, WeekCategory = 1, Year = 2011};
     _accountInfo2 = new AccountInfoDTO { AccountNumber = 3002, AccountName = "testkonto2", IsIncome = true, PartsReportCategory = 2, ResultReportCategory = 2, WeekCategory = 2, Year = 2012 };
     _accountInfo3 = new AccountInfoDTO { AccountNumber = 3003, AccountName = "testkonto3", IsIncome = true, PartsReportCategory = 3, ResultReportCategory = 3, WeekCategory = 3, Year = 2013 };
 }
Ejemplo n.º 2
0
 public void ShouldReturnSuccessStorageResultWhenSuccessful()
 {
     var inputModel = new AccountInfo {AccountNumber = 3000, AccountName = "Test", IsIncome = "Utgift", PartsReportCategory= "Udefinert", ResultReportCategory = "Udefinert", WeekCategory = "Udefinert", Year = 2011};
     var toDb = new AccountInfoDTO {AccountNumber = 3000, AccountName = "Test", IsIncome = false, PartsReportCategory = 0, ResultReportCategory = 0, WeekCategory = 0, Year = 2011};
     _accountInfoRepositoryMock.Setup(x => x.SaveOne(toDb)).Returns(StorageResult.Success);
     var result = _subject.SaveOneAccountInfo(inputModel);
     Assert.That(result, Is.EqualTo(StorageResult.Success));
 }
Ejemplo n.º 3
0
 private static bool IsInCollection(AccountInfoDTO u, IEnumerable<AccountInfoDTO> fromDb)
 {
     foreach (var d in fromDb)
     {
         if (d.Id == u.Id && d.AccountNumber == u.AccountNumber && d.AccountName == u.AccountName && d.IsIncome == u.IsIncome && d.Year == u.Year && d.PartsReportCategory == u.PartsReportCategory && d.ResultReportCategory == u.ResultReportCategory && d.WeekCategory == u.WeekCategory)
             return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public StorageResult DeleteOne(AccountInfoDTO accountCategory)
 {
     try
     {
         using (ISession session = NHibernateHelper.OpenSession())
         using (ITransaction transaction = session.BeginTransaction())
         {
             session.Delete(accountCategory);
             transaction.Commit();
         }
         return StorageResult.Success;
     }
     catch (Exception)
     {
         return StorageResult.Failed;
     }
 }
Ejemplo n.º 5
0
 public void UpdateOne(AccountInfoDTO accountCategory)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     using (ITransaction transaction = session.BeginTransaction())
     {
         session.Update(accountCategory);
         transaction.Commit();
     }
 }
Ejemplo n.º 6
0
        private static IEnumerable<AccountInfoDTO> ConvertDataSetToObjectCollection(DataSet dataSet, int year)
        {
            var allAccountInfos = new List<AccountInfoDTO>();

            foreach (DataRow row in dataSet.Tables["AccountInfo"].Rows)
            {
                if (row[0].ToString() != "")
                {
                    var newAccountInfo = new AccountInfoDTO();
                    newAccountInfo.AccountNumber = Convert.ToInt32(row[0].ToString());
                    newAccountInfo.AccountName = "Udefinert";
                    newAccountInfo.ResultReportCategory = Convert.ToInt32(row[2].ToString());
                    newAccountInfo.PartsReportCategory = Convert.ToInt32(row[3].ToString());
                    newAccountInfo.WeekCategory = Convert.ToInt32(row[4].ToString());
                    newAccountInfo.IsIncome = Convert.ToBoolean(Convert.ToInt32(row[5].ToString()));
                    newAccountInfo.Year = year;
                    allAccountInfos.Add(newAccountInfo);
                }
            }
            return allAccountInfos;
        }
Ejemplo n.º 7
0
 public AccountInfo MapOneForView(AccountInfoDTO accountInfo)
 {
     return new AccountInfo
                 {
                     Id = accountInfo.Id,
                     AccountNumber = accountInfo.AccountNumber,
                     AccountName = accountInfo.AccountName,
                     ResultReportCategory = ((ResultReportCategory)accountInfo.ResultReportCategory).ToString(),
                     PartsReportCategory = ((PartsReportCategory)accountInfo.PartsReportCategory).ToString(),
                     WeekCategory = ((WeekCategory)accountInfo.WeekCategory).ToString(),
                     IsIncome = ((IsIncome)Convert.ToInt32(accountInfo.IsIncome)).ToString(),
                     Year = accountInfo.Year,
                     NumberAndName = accountInfo.AccountNumber + ", " + accountInfo.AccountName
                 };
 }