public IndexAccountDto GetIndexAccount(string code)
        {
            IndexAccountRepository repository   = new IndexAccountRepository();
            IndexAccount           indexAccount = repository.ActiveContext.IndexAccounts
                                                  .Where(ia => ia != null && ia.Code == code)
                                                  .FirstOrDefault();

            if (indexAccount != null)
            {
                IndexAccountDto indexAccountDto = (IndexAccountDto) new IndexAccountDto().InjectFrom <UnflatLoopValueInjection>(indexAccount);
                if (indexAccount.GeneralAccount != null)
                {
                    indexAccountDto.GeneralAccountId = indexAccount.GeneralAccount.Id;
                }
                return(indexAccountDto);
            }
            return(null);
        }
 public string AddIndexAccount(IndexAccountDto indexAccountDto)
 {
     try
     {
         IndexAccountRepository repository     = new IndexAccountRepository();
         GeneralAccount         generalAccount =
             repository.ActiveContext.GeneralAccounts.Include("IndexAccounts")
             .FirstOrDefault(ga => ga.Id == indexAccountDto.GeneralAccountId);
         if (!generalAccount.ContainIndexAccount(code: indexAccountDto.Code))
         {
             IndexAccount indexAccount = new IndexAccount();
             indexAccountDto.Id = Guid.NewGuid();
             indexAccount.InjectFrom <UnflatLoopValueInjection>(indexAccountDto);
             indexAccount.GeneralAccount = generalAccount;
             repository.Add(indexAccount);
             return("has successfully created");
         }
         return("this record with this code was there in database");
     }
     catch (Exception exception)
     {
         return(exception.Message);
     }
 }
 public string AddIndexAccount(IndexAccountDto indexAccountDto)
 {
     try
     {
         IndexAccountRepository repository = new IndexAccountRepository();
         GeneralAccount generalAccount =
             repository.ActiveContext.GeneralAccounts.Include("IndexAccounts")
                       .FirstOrDefault(ga => ga.Id == indexAccountDto.GeneralAccountId);
         if (!generalAccount.ContainIndexAccount(code: indexAccountDto.Code))
         {
             IndexAccount indexAccount = new IndexAccount();
             indexAccountDto.Id = Guid.NewGuid();
             indexAccount.InjectFrom<UnflatLoopValueInjection>(indexAccountDto);
             indexAccount.GeneralAccount = generalAccount;
             repository.Add(indexAccount);
             return "has successfully created";
         }
         return "this record with this code was there in database";
     }
     catch (Exception exception)
     {
         return exception.Message;
     }
 }
Example #4
0
 public void AddIndexAccountTest(Guid id)
 {
     IndexAccountDto indexAccountDto = new IndexAccountDto();
           indexAccountDto.Code = "2/0";
           indexAccountDto.Description = "Bank mell";
           indexAccountDto.HaveAccounts = true;
           indexAccountDto.GeneralAccountCode = 4;
           indexAccountDto.RowId = 0;
           indexAccountDto.GeneralAccountId = id;
           PersonAccountService pa = new PersonAccountService();
           string str = pa.AddIndexAccount(indexAccountDto);
 }