Exemplo n.º 1
0
 public ShowAllExpenseController()
 {
     _IMenu     = new MenuImpl();
     _IExpense  = new ExpenseImpl();
     _IDocument = new DocumentImpl();
     _IUsers    = new UsersImpl();
 }
 public ExpenseController()
 {
     _IExpense  = new ExpenseConcrete();
     _IProject  = new ProjectConcrete();
     _IDocument = new DocumentConcrete();
     _IUsers    = new UsersConcrete();
 }
Exemplo n.º 3
0
 public bool Add(IExpense expense)
 {
     expense.Id          = _expenseRepository.Add(expense);
     expense.CreatedBy   = expense.UserId; //ToDo==>Add these Parameters in Sp
     expense.CreatedDate = DateTime.Now;
     return(_expenseMongoRepository.Add(expense));
 }
Exemplo n.º 4
0
 public void copyProperties(IExpense other)
 {
     other.CheckArgument(nameof(other));
     BillID      = other.BillID;
     Designation = other.Designation;
     Amount      = other.Amount;
     Friend      = other.Friend;
 }
Exemplo n.º 5
0
 public ExpenseController()
 {
     _IMenu = new MenuImpl();
     _IExpense = new ExpenseImpl();
     _IProject = new ProjectImpl();
     _IDocument = new DocumentImpl();
     _IUsers = new UsersImpl();
 }
Exemplo n.º 6
0
        public void Add(IExpense expense)
        {
            expense.CheckArgument(nameof(expense));

            var newItem = new Expense();

            newItem.CopyProperties(expense);
            ExpenseEntities.Add(newItem);
        }
Exemplo n.º 7
0
 public void Update(IExpense expense)
 {
     if (expense.Id <= 0)
     {
         throw new ArgumentException("Expense id should be greater than zero");
     }
     _expenseRepository.Update(expense);
     _expenseMongoRepository.Update(expense);
 }
Exemplo n.º 8
0
 public AccountRepository(AppdbContext context, UserManager <Applicationuser> userManager, IExpense expenserepo, IGroup grouprepo, IActivity activityrepo, ITransaction transactionrepo)
 {
     this.context         = context;
     this.userManager     = userManager;
     this.expenserepo     = expenserepo;
     this.grouprepo       = grouprepo;
     this.activityrepo    = activityrepo;
     this.transactionrepo = transactionrepo;
 }
Exemplo n.º 9
0
        public void Add(IExpense expense)
        {
            expense.CheckArgument(nameof(expense));

            var entity = new Expense();

            entity.CopyProperties(expense);
            ExpenseEntities.Add(entity);
        }
Exemplo n.º 10
0
 public void CopyProperties(IExpense other)
 {
     other.CheckArgument(nameof(other));
     Id          = other.Id;
     TravelId    = other.TravelId;
     Date        = other.Date;
     Description = other.Description;
     Amount      = other.Amount;
     Friend      = other.Friend;
 }
Exemplo n.º 11
0
 public UserController(
     IExpense expenseRepository, IGroup groupRepository, IActivity activityRepository, ITransaction paymentRepository, IAccount accountrepositpry
     )
 {
     this.expenseRepository  = expenseRepository;
     this.groupRepository    = groupRepository;
     this.activityRepository = activityRepository;
     this.paymentRepository  = paymentRepository;
     this.accountrepositpry  = accountrepositpry;
 }
Exemplo n.º 12
0
 public void CopyProperties(IExpense other)
 {
     other.CheckArgument(nameof(other));
     id          = other.id;
     Date        = other.Date;
     Title       = other.Title;
     Description = other.Description;
     Currency    = other.Currency;
     Friends     = other.Friends;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Add an expense Document
 /// </summary>
 /// <param name="expense"></param>
 /// <returns></returns>
 public bool Add(IExpense expense)
 {
     try
     {
         new MongoDBManager().Add <ExpenseMDO>(EXPENSES, this.MapExpenseDomainToDTO(expense));
         return(true);
     }
     catch (WriteConcernException)
     {
         return(false);
     }
 }
Exemplo n.º 14
0
 public bool AddExpense(IExpense expense)
 {
     if (Expenses.Contains(expense))
     {
         return(false);
     }
     else
     {
         Expenses.Add(expense);
     }
     return(true);
 }
Exemplo n.º 15
0
        public void Remove(IExpense expense)
        {
            expense.CheckArgument(nameof(expense));

            var entity = ExpenseEntities.FirstOrDefault(i => (i.Id != 0 && i.Id == expense.Id) ||
                                                        (i.Id == 0 && i.Designation != null && i.Designation.Equals(expense.Designation)));

            if (entity != null)
            {
                ExpenseEntities.Remove(entity);
            }
        }
Exemplo n.º 16
0
        public void Update(IExpense expense)
        {
            MongoDB.Driver.IMongoQuery expenseUpdateConditionQuery = Query.And(MongoDB.Driver.Builders.Query <ExpenseMDO> .Where(e => e.UserId == expense.UserId),
                                                                               MongoDB.Driver.Builders.Query <ExpenseMDO> .Where(e => e.ExpenseId == expense.Id));
            var updateStatements = MongoDB.Driver.Builders.Update
                                   .Set("ExpenseType.TypeId", expense.ExpenseType.TypeId)
                                   .Set("ExpenseType.Type", expense.ExpenseType.Type)
                                   .Set("Amount", expense.Amount)
                                   .Set("Description", expense.Description)
                                   .Set("ModifiedBy", expense.UserId)
                                   .Set("ExpenseDate", expense.ExpenseDate)
                                   .Set("Comments", (expense.Comments == null) ? string.Empty : expense.Comments);

            new MongoDBManager().Update <ExpenseMDO>(EXPENSES, expenseUpdateConditionQuery, updateStatements);
        }
 public ExpenseViewModel MapExpenseDTOToViewModel(IExpense expenseDTO)
 {
     return(new ExpenseViewModel()
     {
         ExpenseId = expenseDTO.ExpenseId,
         UserId = expenseDTO.UserId,
         ExpenseType = this.MapExpenseTypeDTOToViewModel(expenseDTO.Type),
         Amount = expenseDTO.Amount,
         Comments = expenseDTO.Comments,
         Description = expenseDTO.Description,
         CreatedBy = expenseDTO.CreatedBy,
         ExpenseDate = expenseDTO.ExpenseDate.ToString(MyDiary.Common.Constants.DateFormats.ddMMYYYY),
         ModifiedBy = expenseDTO.ModifiedBy
     });
 }
Exemplo n.º 18
0
        public void Remove(IExpense expense)
        {
            expense.CheckArgument(nameof(expense));

            foreach (var item in ExpenseEntities)
            {
                if (item.Id != 0 && item.Id == expense.Id)
                {
                    ExpenseEntities.Remove(item);
                }
                else if (item.Designation != null && item.Designation.Equals(expense.Designation))
                {
                    ExpenseEntities.Remove(item);
                }
            }
        }
Exemplo n.º 19
0
        public int Add(IExpense expenseDomain)
        {
            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Expenses.Expense_Add);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseTypeId, expenseDomain.ExpenseType.TypeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseDate, expenseDomain.ExpenseDate);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Description, expenseDomain.Description);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Comments, expenseDomain.Comments);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Amount, expenseDomain.Amount);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.UserId, expenseDomain.CurrentUser.UserId);
            object result = cmd.ExecuteScalar();

            conn.Close();
            return(int.Parse(result.ToString()));
        }
 private ExpenseJSON Map_ExpenseDTO_To_JSON(IExpense i)
 {
     return(new ExpenseJSON()
     {
         //RowNumber = i.RowNumber,
         ExpenseId = i.ExpenseId,
         ExpenseType = Map_ExpenseTypeDTO_To_JSON(i.Type),
         UserId = i.UserId,
         Amount = i.Amount,
         Description = i.Description,
         ExpenseDate = i.ExpenseDate,
         CreatedBy = i.CreatedBy,
         CreatedDate = i.CreatedDate,
         ModifiedBy = i.ModifiedBy,
         ModifiedDate = i.ModifiedDate,
         Comments = i.Comments
     });
 }
Exemplo n.º 21
0
        public void Update(IExpense expenseDomain)
        {
            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Expenses.Expense_Update);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseId, expenseDomain.Id);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.UserId, expenseDomain.CurrentUser.UserId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseTypeId, expenseDomain.ExpenseType.TypeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.ExpenseDate, expenseDomain.ExpenseDate);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Description, expenseDomain.Description);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Comments, expenseDomain.Comments);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.Amount, expenseDomain.Amount);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Expenses.Parameters.MODIFIEDBY, expenseDomain.CurrentUser.UserId);
            cmd.ExecuteNonQuery();
            cmd.Dispose(); //ToDo ==> If this is success ,implement this in all methods...
            conn.Close();
        }
Exemplo n.º 22
0
 private ExpenseMDO MapExpenseDomainToDTO(IExpense expense)
 {
     return(new ExpenseMDO()
     {
         ExpenseId = expense.Id,
         UserId = expense.UserId,
         ExpenseType = new ExpenseTypeMDO()
         {
             Type = expense.ExpenseType.Type,
             TypeId = expense.ExpenseType.TypeId
         },
         Amount = expense.Amount,
         Description = expense.Description,
         Comments = expense.Comments,
         ExpenseDate = DateTime.Parse(expense.ExpenseDate.ToShortDateString()),
         CreatedBy = expense.CreatedBy,
         CreatedDate = expense.CreatedDate,
         ModifiedBy = expense.ModifiedBy,
         ModifiedDate = expense.ModifiedDate == null ? DateTime.MinValue : expense.ModifiedDate,
     });
 }
Exemplo n.º 23
0
        public bool RemoveExpense(string title)
        {
            IExpense account = null;

            foreach (IExpense acct in Expenses)
            {
                if (acct.ToString().Contains(title))
                {
                    account = acct;
                    break;
                }
            }

            if (account == null)
            {
                return(false);
            }

            Expenses.Remove(account);
            return(true);
        }
Exemplo n.º 24
0
        public void Setup()
        {
            Expense exp1 = new Expense
            {
                Date   = Convert.ToDateTime("2010-01-01"),
                Amount = 100.00M,
                TransactionCategory = "Category 1",
                Description         = "Payee 1"
            };
            Expense exp2 = new Expense
            {
                Date   = Convert.ToDateTime("2011-01-01"),
                Amount = 200.00M,
                TransactionCategory = "Category 2",
                Description         = "Payee 2"
            };

            _expList1.Add(exp1);
            _expList1.Add(exp2);

            var repositoryMock = new Mock <IExpense>();

            repositoryMock.Setup(r => r.GetExpenses()).Returns(_expList1.ToList());
            InputDataSource inputSource = new InputDataSource
            {
                InputDataSourceType = DataSource.FileSystem,
                InputDataSourceName = @"C:\Temp"
            };

            repositoryMock.Setup(r => r.GetSourceDetails()).Returns(inputSource);
            _repo = repositoryMock.Object;

            var mock = new Mock <ILogger <ExpensesController> >();

            _logger = mock.Object;
        }
Exemplo n.º 25
0
        public int RetirementYears(Client client, IExpense expense = null)
        {
            int    years;
            double netWorthAtRetirement;

            if (client.currentAge >= client.targetRetirementAge)
            {
                netWorthAtRetirement = client.netWorth;
            }
            else
            {
                int yearsToRetirement = client.targetRetirementAge - client.currentAge;
                netWorthAtRetirement = client.netWorth + (client.yearlySavingContribution * yearsToRetirement);
            }

            if (expense != null)
            {
                netWorthAtRetirement -= expense.totalExpense();
            }

            years = (int)(netWorthAtRetirement / (client.desiredMonthlySpending * 12));

            return(years);
        }
Exemplo n.º 26
0
 public ExpenseController(IExpense obj)
 {
     exp = obj;
 }
Exemplo n.º 27
0
 public Calculator(IExpense expense)
 {
     this.expense = expense;
 }
Exemplo n.º 28
0
 public ExpenseController()
 {
     expenseRepo = new ExpenseRepo();
 }
Exemplo n.º 29
0
 public ExpenseController(IExpense expenseRepository)
 {
     this.expenseRepository = expenseRepository;
 }
Exemplo n.º 30
0
 public virtual bool UpsertExpense(IExpense pExpense)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 31
0
 public virtual void AddReceipt(IExpense pExpense, System.Drawing.Image pImage)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserDashboardController"/> class.
 /// </summary>
 public UserDashboardController()
 {
     _ITimeSheet = new TimeSheetConcrete();
     _IExpense   = new ExpenseConcrete();
 }
Exemplo n.º 33
0
 /// <summary>
 /// Adds a "expense" to the expenselist
 /// </summary>
 /// <param name="pExpense"></param>
 public void AddExpense(IExpense pExpense)
 {
     ExpenseList.Add(pExpense);
     List<InteractionAttributes> changedAttributes = new List<InteractionAttributes>();
     changedAttributes.Add(InteractionAttributes.ExpenseList);
     OnModify(new InteractionEventArgs($"Survey IsActive changed [Id={Id}]", DateTime.Now, InteractionType.Account));
 }
Exemplo n.º 34
0
 public HomeController(ILogger <HomeController> logger, ICategory category, IExpense expense)
 {
     _logger   = logger;
     _category = category;
     _expense  = expense;
 }
Exemplo n.º 35
0
 /// <summary>
 /// Deletes a "expense" object if it exists in the expenselist
 /// </summary>
 /// <param name="pExpense"></param>
 public void DeleteExpense(IExpense pExpense)
 {
     if (ExpenseList.Contains(pExpense))
     {
         ExpenseList.Remove(pExpense);
         List<InteractionAttributes> changedAttributes = new List<InteractionAttributes>();
         changedAttributes.Add(InteractionAttributes.ExpenseList);
         OnModify(new InteractionEventArgs($"Survey user list changed [Id={Id}]", DateTime.Now, InteractionType.Account));
     }
 }
Exemplo n.º 36
0
 public int CompareTo(IExpense other)
 {
     if ((IExpense)this == other)
         return 0;
     return 1;
 }
Exemplo n.º 37
0
 public virtual void DeleteExpense(IExpense pExpense)
 {
     throw new System.NotImplementedException();
 }