Ejemplo n.º 1
0
        public ActionResult LimitMgmt(Guid id)
        {
            using (var fact = Wcf <UserAccountService>())
            {
                var         channel  = fact.CreateChannel();
                TB_UserInfo userInfo = channel.QuerySingle(new TB_UserInfoQueryObject {
                    QueryCondition = t => t.UserUid == id
                }).Cast <TB_UserInfo>();
                TB_UserAuthenCodes userAuthenCodes = channel.QuerySingle(new TB_UserAuthenCodesQueryObject {
                    QueryCondition = t => t.UserUid == id
                }).Cast <TB_UserAuthenCodes>();

                UserViewModel userViewModel = new UserViewModel();
                userViewModel.UserUid     = id;
                userViewModel.LoginId     = userInfo?.LoginId;
                userViewModel.Name        = userInfo?.NickName;
                userViewModel.LimitCode   = userAuthenCodes?.UserLimitCodes;
                userViewModel.DisplayCode = userAuthenCodes?.UserDisplayCodes;

                LimitViewModel limitViewModel = new LimitViewModel();
                limitViewModel.UserViewModel   = userViewModel;
                limitViewModel.LimitCodeList   = channel.QueryAll(new TB_LimitCodeQueryObject()).Cast <List <TB_LimitCode> >();
                limitViewModel.DisplayCodeList = channel.QueryAll(new TB_DisplayCodeQueryObject()).Cast <List <TB_DisplayCode> >();

                return(View(limitViewModel));
            }
        }
Ejemplo n.º 2
0
        public (int, double) StoreLimit(LimitViewModel viewModel)
        {
            Limit limit;

            if (viewModel.Id.HasValue && viewModel.Id != 0)
            {
                limit = repository.Limits.FirstOrDefault(x => x.Id == viewModel.Id);
            }
            else
            {
                limit = new Limit();
                repository.Add(limit);
            }

            limit.LimitAmount = viewModel.Limit;
            limit.Category    = repository.Categories.FirstOrDefault(x => x.Id == viewModel.CategoryId);

            repository.SaveChanges();

            var sum = repository.Expenses.Where(x => x.Category == limit.Category).Sum(x => x.Amount);

            return(limit.Id, sum);
        }
Ejemplo n.º 3
0
        public ActionResult SubmitLimit([FromBody] LimitViewModel viewModel)
        {
            var response = StoreLimit(viewModel);

            return(Ok(new { Id = response.Item1, ActualAmount = response.Item2 }));
        }