public TransactionDialogViewModel(Action <TransactionDialogViewModel> closeHandler)
        {
            Cancel = false;
            var CategRepo = new CategoryRepository();
            var ShopRepo  = new ShopRepository();

            ShoppingPlaceDistinct = new ObservableCollection <Shop>(ShopRepo.Shops);
            Categories            = new ObservableCollection <Category>(CategRepo.Categories);

            TxRecord = new Transaction()
            {
                Date = DateTime.Now
            };

            CloseTxAddDialogCommand = new SimpleCommand
            {
                ExecuteDelegate = o =>
                {
                    Cancel = true;
                    closeHandler(this);
                }
            };
            ConfirmTxAddDialogCommand = new SimpleCommand {
                ExecuteDelegate = o => closeHandler(this)
            };
        }
Beispiel #2
0
        public DrinkView[] GetDetailViews()
        {
            var curShop = ShopRepository.GetShops().FirstOrDefault(a => a.Id == CurrentShopId);

            if (CurrentShopId == null)
            {
                return(null);
            }

            var curDrink = ShopRepository.GetShopBeerTypes(curShop).FirstOrDefault(a => a.Id == SelectedBeerType);

            var res = curDrink != null
                ? ShopRepository.GetDrinkCash(curDrink.Id, FilterDateStart.GetValueOrDefault(),
                                              FilterDateEnd.GetValueOrDefault()).Where(a => a.Key.Id == CurrentShopId)
                      .SelectMany(a => a.Value.Select(b => new DrinkView {
                Drink = curDrink, Summary = b
            }))
                      .ToArray()
                : ShopRepository.GetShopCash(CurrentShopId.Value, FilterDateStart.GetValueOrDefault(),
                                             FilterDateEnd.GetValueOrDefault())
                      .SelectMany(a => a.Value.Select(b => new DrinkView {
                Drink = a.Key, Summary = b
            }))
                      .ToArray();

            return(res);
        }
Beispiel #3
0
        /// <summary>
        /// 更新合同信息信息
        /// </summary>
        /// <param name="inputDtos">包含更新信息的合同信息DTO信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult EditContracts(params ContractInputDto[] inputDtos)
        {
            return(ContractRepository.Update(inputDtos,
                                             (dto, entity) => {
                if (entity.State == ContractState.Settlling || entity.State == ContractState.Finish)
                {
                    throw new Exception("合同处于清算阶段或已结束,不能编辑");
                }
            },
                                             (dto, entity) => {
                if (dto.ShopId.HasValue && dto.ShopId.Value > 0)
                {
                    Hmh.Core.Shop.Models.Shop shop = ShopRepository.GetByKey(dto.ShopId.Value);
                    if (shop == null)
                    {
                        throw new Exception("合同所属店铺不存在");
                    }

                    Contract usingContract = shop.Contracts.FirstOrDefault(c => c.State == ContractState.Using);
                    if (usingContract != null && dto.BeginTime < usingContract.EndTime)
                    {
                        throw new Exception("新合同和执行中的合同时间重合");
                    }
                    shop.CurrentContract = entity;
                    shop.Contracts.Add(entity);
                    entity.Shop = shop;
                }
                else
                {
                    throw new Exception("合同没有归属店铺");
                }

                return entity;
            }));
        }
 public CustomerController()
 {
     // web api location
     webApiUri      = "https://localhost:44325/customer";
     client         = new HttpClient();
     shopRepository = new ShopRepository();
 }
Beispiel #5
0
        public ActionResult AddPayBaseRecord(string PayDate, string PayNum, string NextPayDate, string NextPayNum, string shopID, int?id)
        {
            if (Convert.ToInt32(PayNum) <= 0)
            {
                return(Json(new { state = false, message = "付款金额不得小于等于0!" }));
            }
            if (Convert.ToInt32(NextPayNum) <= 0)
            {
                return(Json(new { state = false, message = " 下次付款金额不得小于等于0!" }));
            }
            if (NextPayDate.ToDateTime() <= PayDate.ToDateTime())
            {
                return(Json(new { state = false, message = " 下次时间不得早于本次付款时间!" }));
            }
            PayRecords payRecord = new PayRecords();

            if (id != null && id.Value > 0)
            {
                payRecord = this.PayRecordsRepo.GetByDatabaseID(Convert.ToInt32(id));
            }
            try
            {
                //赋值

                payRecord._PayType = _PayType.基础服务费;

                payRecord.PayDate     = PayDate.ToDateTime();
                payRecord.PayNum      = PayNum.ToInt();
                payRecord.SaleVolume  = 0;
                payRecord.UpdateTime  = System.DateTime.Now;
                payRecord.Year        = PayDate.ToDateTime().Year;
                payRecord.Month       = PayDate.ToDateTime().Month;
                payRecord.NextPayNum  = NextPayNum.ToInt();
                payRecord.NextPayDate = NextPayDate.ToDateTime();
                //保存
                PayRequireRecordsRepository payRequireRecordsRepo = new PayRequireRecordsRepository();
                if (id != null && id.Value > 0)
                {
                    payRecord.ConfirmUser = payRecord._Shop.MainKfUser;
                    payRecord.DemandUser  = payRecord._Shop.MainKfUser;
                    this.PayRecordsRepo.Update(payRecord);
                    //根据PayRecords更新PayRequireRecords
                    payRequireRecordsRepo.AddPayRequireRecords(payRecord);
                }
                else
                {
                    ShopRepository shopRepo = new ShopRepository();
                    payRecord._Shop       = shopRepo.GetByDatabaseID(Convert.ToInt32(shopID));
                    payRecord.ConfirmUser = payRecord._Shop.MainKfUser;
                    payRecord.DemandUser  = payRecord._Shop.MainKfUser;
                    this.PayRecordsRepo.Save(payRecord);
                    payRequireRecordsRepo.AddPayRequireRecords(payRecord);
                }
                return(Json(new { state = true, message = "操作成功!" }));
            }
            catch (RuleException ex)
            {
                throw new RuleException(ex.Message, ex);
            }
        }
Beispiel #6
0
        public ActionResult AddPayTiChengRecord(string id, string shopID)
        {
            //shopID不为空的时候是添加,为空的时候是修改。
            //ShopID,PayTypeID,PayDate,SaleVolume,PayNum,NextPayDate,NextPayNum,DemandUserID,ConfirmUserID
            //取出数据来做DROPDOWNLIST的传递。

            if (id != null)
            {
                PayRecords PayRecord = this.PayRecordsRepo.GetByDatabaseID(Convert.ToInt32(id));
                ViewBag.Edit = "1";
                return(View(PayRecord));
            }
            ShopRepository shopRepo = new ShopRepository();
            Shop           shop     = shopRepo.GetByDatabaseID(Convert.ToInt32(shopID));

            ViewData["shopID"] = shopID;
            PayRecords payRecord = new PayRecords();

            payRecord.PayNum      = 0;
            payRecord.PayDate     = System.DateTime.Today;
            payRecord.NextPayNum  = 0;
            payRecord.NextPayDate = System.DateTime.Today.AddDays(15);

            return(View(payRecord));
        }
Beispiel #7
0
 /// <summary>
 /// 更新信息信息
 /// </summary>
 /// <param name="inputDtos">包含信息的店铺信息DTO信息</param>
 /// <returns>业务操作结果</returns>
 public OperationResult EditShops(params ShopInputDto[] inputDtos)
 {
     return(ShopRepository.Update(inputDtos,
                                  (dto, entity) =>
     {
         if (ShopRepository.CheckExists(shop => shop.Name == dto.Name, dto.Id))
         {
             throw new Exception("店铺名称:{0}已经存在,不能添加同名店铺".FormatWith(dto.Name));
         }
     },
                                  (dto, entity) =>
     {
         if (!dto.UserId.HasValue || dto.UserId == 0)
         {
             entity.User = null;
         }
         else if (entity.User != null && entity.User.Id != dto.UserId)
         {
             User user = UserRepository.GetByKey(dto.UserId.Value);
             if (user == null)
             {
                 throw new Exception("指定的开店人不存在");
             }
             entity.User = user;
         }
         return entity;
     }));
 }
Beispiel #8
0
        static void Main(string[] args)
        {
            CountryRepository cr = new CountryRepository();

            // var jskl = cr.GetAll();
            //var res = cr.GetById(new Guid("0a0c816a-5e8f-404c-bc43-c3d76c8d8761"));
            Console.WriteLine("erewwe");

            ProductRepository pr = new ProductRepository();

            List <string> products = new List <string>()
            {
                "Мука", "Молоко", "Яйца", "Яблоко", "Сахар"
            };
            //var res = pr.GetNearest(products, 27.46238, 53.90399);
            var res = pr.GetAllProductsInShop(new Guid("b869aea6-a868-4180-b226-6eeac0292525"));

            //Product product = pr.GetCheapestInCity("Молоко", "Минск");
            //pr.GetById(new Guid("14781a9d-80f0-41f5-9a70-c93cd6d6f6dd"));

            //var jklj = pr.GetNearest("Молоко", 27.46238, 53.90399, 0, 5);

            //var sfdjkl = pr.GetCheapestInCity("Молоко", "Гродно", 0, 10);

            ShopRepository sr = new ShopRepository();

            //var rr = pr.GetOpt("Молоко", "Сыр", "Минск");
            //var res32 = sr.GetAllShopsInCity("Минск");

            CityRepository cp = new CityRepository();

            //var jklj = cp.GetAll("Беларусь");

            Console.WriteLine();
        }
Beispiel #9
0
        //PayRecordManageIndex
        //实收款管理
        public ActionResult PayRecordManageIndex(QueryInfo queryInfo, int[] ids, string name, string alertMessage, string subAction)
        {
            ShopRepository   shopRepo = new ShopRepository();
            PagedData <Shop> data     = shopRepo.GetData(queryInfo, null, name, this.Users().DepartMent);

            return(View(data));
        }
Beispiel #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //Sqlite
            string dbPath = FileAccessHelper.GetLocalFilePath("listacompras.db3");

            ShopRepository = new ShopRepository(dbPath);
            //Akavache Init Persintent Data
            Akavache.Registrations.Start("Pedidos");
            SetContentView(Resource.Layout.Main);
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            base.SetSupportActionBar(toolbar);
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawerLayout);
            var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close);

            drawerLayout.AddDrawerListener(drawerToggle);
            drawerToggle.SyncState();
            var menu = FindViewById <Android.Support.Design.Widget.NavigationView>(Resource.Id.navigationView);

            menu.NavigationItemSelected += OnMenuItemSelected;
            Navigate(new HomeFragment());
            //Navigate(new HomeFragmentRecicler());
        }
 public UnitOfWork(ApplicationDbContext context)
 {
     Shops    = new ShopRepository(context);
     Comments = new CommentRepository(context);
     Images   = new ImageRepository(context);
     _context = context;
 }
        public async void PlaceOrder()
        {
            try
            {
                Order placedOrder = await ShopRepository.PostOrder(ShoppingCart);

                if (placedOrder is null)
                {
                    throw new Exception("Order can't be empty");
                }

                _passenger.ShoppingCart = new Order(_passenger);
                RefreshCart();
                if (_passenger.Orders is null)
                {
                    _passenger.Orders = new List <Order>();
                }
                _passenger.Orders.Add(placedOrder);

                HasOrders = true;
                MessageDialog messageDialog = new MessageDialog($"Thank you for your order!\nYour order is being processed by our staff members");
                messageDialog.Commands.Add(new UICommand("Close"));
                messageDialog.CancelCommandIndex = 0;
                await messageDialog.ShowAsync();
            }
            catch (Exception e)
            {
                MessageDialog messageDialog = new MessageDialog($"Error trying to place order. \n{e.Message}");
                messageDialog.Commands.Add(new UICommand("Close"));
                messageDialog.CancelCommandIndex = 0;
                await messageDialog.ShowAsync();
            }
        }
Beispiel #13
0
 /// <summary>
 /// 添加合同信息信息
 /// </summary>
 /// <param name="inputDtos">要添加的合同信息DTO信息</param>
 /// <returns>业务操作结果</returns>
 public OperationResult AddShopPermits(params ShopPermitInputDto[] inputDtos)
 {
     return(ShopPermitRepository.Insert(inputDtos,
                                        dto =>
     {
         //认证为待审核状态
         dto.State = ShopPermitState.Verifying;
     },
                                        (dto, entity) => {
         if (dto.ShopId.HasValue && dto.ShopId.Value > 0)
         {
             Models.Shop shop = ShopRepository.GetByKey(dto.ShopId.Value);
             if (shop == null)
             {
                 throw new Exception("所属店铺不存在");
             }
             shop.ShopPermit = entity;
             entity.Shop = shop;
         }
         else
         {
             throw new Exception("没有归属店铺");
         }
         return entity;
     }));
 }
 public ActionResult ManageUser(string id)
 {
     if (User.IsInRole("Administrator") && id != null)
     {
         using (var repo = new ShopRepository())
         {
             var user = repo.GetUserById(id);
             using (var context = new ShopContext())
             {
                 var model = new ManageUserViewModel
                 {
                     FirstName           = user.FirstName,
                     LastName            = user.LastName,
                     Email               = user.Email,
                     UserName            = user.UserName,
                     LockoutEnabled      = user.LockoutEnabled,
                     ProfilePicture      = user.ProfilePicture,
                     LockoutEndDateUtc   = user.LockoutEndDateUtc,
                     AccessFailedCounter = user.AccessFailedCount
                 };
                 return(View(model));
             }
         }
     }
     else
     {
         return(RedirectToAction("Error", "Shared"));
     }
 }
Beispiel #15
0
        public void ShouldGetShop()
        {
            Guid           id   = new Guid("1B990E1C-3D52-E811-BFD3-001583C810FA");
            ShopRepository repo = new ShopRepository();
            Shop           shop = repo.GetShop(id);

            Assert.AreEqual(id, shop.Id);
        }
Beispiel #16
0
 public ShopViewModel(IDialogCoordinator dialogCoordinator)
 {
     this.dialogCoordinator = dialogCoordinator;
     ShopRepository         = new ShopRepository();
     Shops = new ObservableCollection <Shop>(ShopRepository.Shops);
     ReorderShopList();
     AddNewCommand = new RelayCommand <object>(AddNewShop);
     RemoveCommand = new RelayCommand <object>(RemoveShop);
     EditCommand   = new RelayCommand <object>(EditShop);
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitOfWork"/> class.
 /// </summary>
 /// <param name="context">Database context.</param>
 public UnitOfWork(PayingSystemDataBaseContext context)
 {
     Context               = context;
     AccountRepository     = new AccountRepository(context);
     ClientRepository      = new ClientRepository(context);
     AddressRepository     = new AddressRepository(context);
     ShopRepository        = new ShopRepository(context);
     ProductListRepository = new ProductListRepository(context);
     ProductRepository     = new ProductRepository(context);
 }
Beispiel #18
0
 public UnitOfWork(JPartsContext context)
 {
     _context  = context;
     Addresses = new AddressRepository(_context);
     Cars      = new CarRepository(_context);
     Clients   = new ClientRepository(_context);
     Orders    = new OrderRepository(_context);
     Parts     = new PartRepository(_context);
     Shops     = new ShopRepository(_context);
 }
Beispiel #19
0
 public UnitOfWork(ShopContext context)
 {
     _context     = context;
     Shops        = new ShopRepository(context);
     Cashboxes    = new CashboxRepository(context);
     Transactions = new TransactionRepository(context);
     Cashiers     = new CashierRepository(context);
     Orders       = new OrderRepository(context);
     Products     = new ProductRepository(context);
     Categories   = new CategoryRepository(context);
 }
 public ShopController(IOptions <WebApiSettings> settings,
                       UserManager <EaUser> userManager,
                       ShopRepository shopRepository,
                       ShopItemRepository shopItemRepository,
                       BuyRepository buyRepository)
 {
     _settings           = settings;
     _userManager        = userManager;
     _shopRepository     = shopRepository;
     _buyRepository      = buyRepository;
     _shopItemRepository = shopItemRepository;
 }
Beispiel #21
0
 public ServiceBase()
 {
     try
     {
         _repository = new ShopRepository();
     }
     catch (TypeInitializationException ex)
     {
         Trace.WriteLine(ex.InnerException);
         throw;
     }
 }
Beispiel #22
0
        //retailPlaceAddress - строка с адресом магазина
        public void ParseJsonData(Guid customerId)
        {
            ShopRepository        shopRepository        = new ShopRepository();
            CustomerRepository    customerRepository    = new CustomerRepository();
            PurchaseRepository    purchaseRepository    = new PurchaseRepository();
            ProductRepository     productRepository     = new ProductRepository();
            ProductItemRepository productItemRepository = new ProductItemRepository();

            Shop shop = shopRepository.CreateShop(
                (long)_jsonData["document"]["receipt"]["userInn"],
                (string)_jsonData["document"]["receipt"]["user"],
                (string)_jsonData["document"]["receipt"]["retailPlaceAddress"]);

            Customer customer = customerRepository.GetCustomer(customerId);

            Purchase purchase = purchaseRepository.CreatePurchase(
                customer.Id,
                shop.Id,
                (DateTime)_jsonData["document"]["receipt"]["dateTime"],
                (decimal)_jsonData["document"]["receipt"]["totalSum"] / 100);

            //purchase.CustomerId = customer.Id;
            //purchase.Customer = customer;

            //purchase.ShopId = shop.Id;
            //purchase.Shop = shop;

            //purchase.Date = (DateTime) _jsonData["document"]["receipt"]["dateTime"];
            //purchase.PurchaseSum = (decimal)_jsonData["document"]["receipt"]["totalSum"] / 100;

            JArray items = (JArray)_jsonData["document"]["receipt"]["items"];

            foreach (var item in items)
            {
                Product     product     = productRepository.CreateProduct((string)item["name"]);
                ProductItem productItem = productItemRepository.CreateProductItem(
                    product.Id,
                    purchase.Id,
                    (decimal)item["price"] / 100,
                    (decimal)item["quantity"],
                    (decimal)item["sum"] / 100);
                //ProductItem productItem = new ProductItem();
                //productItem.Price = (decimal) item["price"] / 100;
                //productItem.Quantity = (decimal) item["quantity"];
                //productItem.Sum = (decimal) item["sum"] / 100;
                //productItem.ProductId = product.Id;
                //productItem.Product = product;
                //productItem.PurchaseId = purchase.Id;
                //productItem.Purchase = purchase;
            }
            Console.WriteLine("Parsed and added to database.");
        }
Beispiel #23
0
        protected IRetailDistributionUnitOfWork GetUnitOfWork()
        {
            TestRetailDistributionContext contextMock = new TestRetailDistributionContext();
            var vendor1 = contextMock.Vendors.Add(new Vendor {
                VendorId = 1, VendorName = "Vendor1"
            });
            var vendor2 = contextMock.Vendors.Add(new Vendor {
                VendorId = 2, VendorName = "Vendor2"
            });
            var vendor3 = contextMock.Vendors.Add(new Vendor {
                VendorId = 3, VendorName = "Vendor3"
            });

            var district1 = contextMock.Districts.Add(new District {
                DistrictId = 1, DistrictName = "District1", PrimaryVendor = vendor2
            });
            var district2 = contextMock.Districts.Add(new District {
                DistrictId = 2, DistrictName = "District2", PrimaryVendor = vendor2
            });
            var district3 = contextMock.Districts.Add(new District {
                DistrictId = 3, DistrictName = "District3", PrimaryVendor = vendor1
            });

            contextMock.Shops.Add(new Shop {
                ShopId = 1, ShopName = "Shop1", District = district1
            });
            contextMock.Shops.Add(new Shop {
                ShopId = 2, ShopName = "Shop2", District = district2
            });
            contextMock.Shops.Add(new Shop {
                ShopId = 3, ShopName = "Shop3", District = district1
            });

            contextMock.DistrictVendors.Add(new DistrictVendor {
                VendorId = 3, Vendor = vendor3, District = district3, DistrictId = 3
            });
            contextMock.DistrictVendors.Add(new DistrictVendor {
                VendorId = 2, Vendor = vendor2, District = district1, DistrictId = 1
            });
            contextMock.DistrictVendors.Add(new DistrictVendor {
                VendorId = 2, Vendor = vendor2, District = district2, DistrictId = 2
            });
            contextMock.DistrictVendors.Add(new DistrictVendor {
                VendorId = 1, Vendor = vendor1, District = district3, DistrictId = 3
            });

            var districtRepository = new DistrictRepository(contextMock);
            var vendorRepository   = new VendorRepository(contextMock);
            var shopRepository     = new ShopRepository(contextMock);

            return(new RetailDistributionUnitOfWork(contextMock, districtRepository, vendorRepository, shopRepository));
        }
Beispiel #24
0
        public void ShouldCreateShop()
        {
            long   inn     = 12345678;
            string name    = "Lenta";
            string address = "Komendantskiy pr-t 53";

            ShopRepository repo = new ShopRepository();
            Shop           shop = repo.CreateShop(inn, name, address);

            Assert.AreEqual(inn, shop.Inn);
            Assert.AreEqual(name, shop.Name);
            Assert.AreEqual(address, shop.Address);
        }
Beispiel #25
0
        public ShopManager()
        {
            _shoprepository = new ShopRepository();

            var conf = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Product, ProductDTO>();
                cfg.CreateMap <Group, GroupDTO>();
                cfg.CreateMap <ProductDTO, Product>();
            });

            _mapper = new Mapper(conf);
        }
Beispiel #26
0
 public UnitOfWork(RoleplayContext context)
 {
     _context                    = context;
     AccountRepository           = new AccountRepository(_context);
     CharacterRepository         = new CharacterRepository(_context);
     VehicleRepository           = new VehicleRepository(_context);
     AtmRepository               = new AtmRepository(_context);
     BusRepository               = new BusRepository(_context);
     BuildingRepository          = new BuildingRepository(_context);
     ItemRepository              = new ItemRepository(_context);
     ShopRepository              = new ShopRepository(_context);
     GroupRepository             = new GroupRepository(_context);
     WarehouseRepository         = new WarehouseRepository(_context);
     SmartphoneMessageRepository = new SmartphoneMessageRepository(_context);
 }
Beispiel #27
0
 private async void LoadOrders()
 {
     try
     {
         Orders = (await ShopRepository.GetOrdersAsync()).OrderByDescending(o => o.TimeStamp);
     }
     catch (Exception e)
     {
         MessageDialog messageDialog = new MessageDialog($"Couldn't establish a connection to the database. \n{e.Message}");
         messageDialog.Commands.Add(new UICommand("Try again", new UICommandInvokedHandler(this.CommandInvokedHandler)));
         messageDialog.Commands.Add(new UICommand("Close"));
         messageDialog.DefaultCommandIndex = 0;
         messageDialog.CancelCommandIndex  = 1;
         await messageDialog.ShowAsync();
     }
 }
Beispiel #28
0
        /// <summary>
        /// 添加信息信息
        /// </summary>
        /// <param name="inputDtos">要添加的信息DTO信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult AddShops(params ShopInputDto[] inputDtos)
        {
            return(ShopRepository.Insert(inputDtos,
                                         dto =>
            {
                if (ShopRepository.CheckExists(shop => shop.Name == dto.Name))
                {
                    throw new Exception("店铺名称:{0}已经存在,不能添加同名店铺".FormatWith(dto.Name));
                }
            },
                                         (dto, entity) =>
            {
                if (dto.UserId.HasValue && dto.UserId.Value > 0)
                {
                    User user = UserRepository.GetByKey(dto.UserId.Value);
                    if (user == null)
                    {
                        throw new Exception("店铺开店人不存在");
                    }
                    if (ShopRepository.CheckExists(shop => shop.User.Id == dto.UserId.Value))
                    {
                        throw new Exception("您已经拥有店铺");
                    }
                    user.Shop = entity;
                    entity.User = user;
                }
                else
                {
                    throw new Exception("店铺不能没有开店人");
                }

                if (dto.RegionId.HasValue && dto.RegionId.Value > 0)
                {
                    Region region = RegionRepository.GetByKey(dto.RegionId.Value);
                    if (region != null)
                    {
                        entity.Region = region;
                    }
                    else
                    {
                        throw new Exception("地区不存在");
                    }
                }

                return entity;
            }));
        }
Beispiel #29
0
        public ActionResult AddPayBaseRecord(string id, string shopID)
        {
            //shopID不为空的时候是添加,为空的时候是修改。
            //ShopID,PayTypeID,PayDate,SaleVolume,PayNum,NextPayDate,NextPayNum,DemandUserID,ConfirmUserID
            //取出数据来做DROPDOWNLIST的传递。
            if (id != null)
            {
                PayRecords PayRecord = this.PayRecordsRepo.GetByDatabaseID(Convert.ToInt32(id));
                ViewBag.Edit = "1";
                return(View(PayRecord));
            }
            ShopRepository shopRepo = new ShopRepository();
            Shop           shop     = shopRepo.GetByDatabaseID(Convert.ToInt32(shopID));

            ViewData["shopID"] = shopID;
            PayRecords payRecord = new PayRecords();

            payRecord.PayDate = System.DateTime.Today;
            switch (shop._PayCircle)
            {
            case _PayCircle.月付:
                payRecord.NextPayDate = System.DateTime.Today.AddDays(30);
                payRecord.PayNum      = shop.PriceByMonth;
                payRecord.NextPayNum  = shop.PriceByMonth;
                break;

            case _PayCircle.季付:
                payRecord.NextPayDate = System.DateTime.Today.AddDays(90);
                payRecord.PayNum      = shop.PriceByMonth * 3;
                payRecord.NextPayNum  = shop.PriceByMonth * 3;
                break;

            case _PayCircle.半年:
                payRecord.NextPayDate = System.DateTime.Today.AddDays(180);
                payRecord.PayNum      = shop.PriceByMonth * 6;
                payRecord.NextPayNum  = shop.PriceByMonth * 6;
                break;

            case _PayCircle.一年:
                payRecord.NextPayDate = System.DateTime.Today.AddDays(365);
                payRecord.PayNum      = shop.PriceByMonth * 12;
                payRecord.NextPayNum  = shop.PriceByMonth * 12;
                break;
            }
            return(View(payRecord));
        }
        public ActionResult ManageUser(ManageUserViewModel manageUserViewModel)
        {
            using (ShopRepository _repo = new ShopRepository())
            {
                var user = _repo.GetUserById(manageUserViewModel.Id);

                if (ModelState.IsValid)
                {
                    user.LockoutEnabled = manageUserViewModel.LockoutEnabled;
                    _repo.Save();

                    return(Redirect(Request.RawUrl));
                }

                return(RedirectToAction("Error", "Shared"));
            }
        }