Exemplo n.º 1
0
        public async Task <JsonResult> Edit(DailyGoldPriceViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(Json(false, data: ErrorToDictionary()));
            }

            var dailyGoldPrice = new DailyGoldPrice()
            {
                Id          = viewModel.Id,
                ColorFormId = viewModel.ColorFormId,
                CompanyId   = User.CompanyId,
                CreatorId   = User.Id,
                Price       = viewModel.Price,
                Date        = Convert.ToDateTime(viewModel.Date)
            };
            var manager = new DailyGoldPriceManager(User);
            var result  = await manager.SaveDailyGoldPrice(dailyGoldPrice);

            return(Json(result));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Edit(int id = 0)
        {
            var manager = new DailyGoldPriceManager(User);
            var dailyGoldPriceViewModel = new DailyGoldPriceViewModel();

            if (id > 0)
            {
                var dailyGoldPrice = await manager.GetDailyGoldPriceAsync(id);

                if (dailyGoldPrice != null)
                {
                    dailyGoldPriceViewModel = new DailyGoldPriceViewModel(dailyGoldPrice);
                }
            }

            var colorFormManager = new BasicDataManager(User);

            dailyGoldPriceViewModel.ColorForms = await colorFormManager.GetColorFormsAsync();

            return(View(dailyGoldPriceViewModel));
        }