Ejemplo n.º 1
0
        public bool CreateAction(InputCountParametrs inputCountParametrs)
        {
            ////TODO
            ////Mapper
            bool result = true;

            using (CashCountRepository repository = new CashCountRepository())
            {
                DataLayer.DataModels.CashCount count = new DataLayer.DataModels.CashCount()
                {
                    Name          = inputCountParametrs.Name,
                    AmountOfMoney = inputCountParametrs.AmountOfMoney,
                    Comment       = inputCountParametrs.Comment,
                    Valuta        = inputCountParametrs.Valuta,
                    UserId        = MyUser.UserId,
                    PeriodChanges = false
                };
                try
                {
                    repository.Create(count);
                    repository.Save();
                }
                catch
                {
                    result = false;
                }
            }

            return(result);
        }
        public float GetTotalSumOfCounts()
        {
            float result;

            using (CashCountRepository repository = new CashCountRepository())
            {
                result = repository.GetTotalSumOfCounts(MyUser.UserId);
            }
            return(result);
        }
        public int GetTotalNumberOfCounts()
        {
            int result;

            using (CashCountRepository repository = new CashCountRepository())
            {
                result = repository.GetTotalNumberOfCounts(MyUser.UserId);
            }
            return(result);
        }
        public bool UpdatePeriodChanges(int id)
        {
            bool result;

            using (CashCountRepository repository = new CashCountRepository())
            {
                result = repository.UpdatePeriodChanges(id);
                repository.Save();
            }
            return(result);
        }
        public CashCountInfo GetCashCountInfoById(int id)
        {
            CashCountInfo cash = new CashCountInfo();

            using (CashCountRepository repository = new CashCountRepository())
            {
                CashCount cashCount = repository.GetItem(id);
                cash.AmountOfMoney = cashCount.AmountOfMoney;
                cash.Comment       = cashCount.Comment;
                cash.Id            = cashCount.Id;
                cash.Name          = cashCount.Name;
                cash.Valuta        = cashCount.Valuta;
            }

            return(cash);
        }
        public List <OneCashCountViewVM> GetCashCounts()
        {
            List <OneCashCountViewVM> resultlist = new List <OneCashCountViewVM>();

            using (ICashCountRepository repository = new CashCountRepository())
            {
                ICollection <CashCount> list = repository.GetCashCountsByUserId(MyUser.UserId);

                CashCountViewInList cashcount = new CashCountViewInList();

                foreach (CashCount count in list)
                {
                    CashCountViewInList cash = cashcount.Clone() as CashCountViewInList;

                    cash.AmountOfMoney = count.AmountOfMoney;
                    cash.Id            = count.Id;
                    cash.Name          = count.Name;
                    cash.PeriodChanges = count.PeriodChanges;

                    resultlist.Add(new OneCashCountViewVM(cash));
                }
            }
            return(resultlist);
        }