public ActionResult GetSaleInfos()
        {
            var saleInfos = new SaleInfoRepository().Items.ToList();
            var res       = Mapper.Map <IList <SaleInfo>, IList <SaleInfoModel> >(saleInfos);

            return(PartialView("SaleInfoView", res));
        }
        public ActionResult GetManagerGraphic()
        {
            var srep = new SaleInfoRepository();
            var mrep = new ManagerRepository();

            var saleInfos = srep.Items.ToList();
            var managers  = mrep.Items.ToList();
            var dict      = managers.ToDictionary(manager => manager.Id, manager => 0);


            int total = saleInfos.Count;

            foreach (var saleInfo in saleInfos)
            {
                var _manager = saleInfo.FileInformation.Manager;
                try
                {
                    dict[_manager.Id]++;
                }
                catch (Exception e)
                { }
            }


            var res = new List <KeyValuePair <string, int> >();

            foreach (var entry in dict)
            {
                var manag = managers.FirstOrDefault(manager => manager.Id == entry.Key);
                res.Add(new KeyValuePair <string, int>(manag.SecondName, entry.Value));
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
        public ActionResult EditSaleInfo(int id)
        {
            var _saleInfo = new SaleInfoRepository().SaleInfoObjectById(id);

            if (_saleInfo == null)
            {
                return(View("Error"));
            }

            var saleInfo = Mapper.Map <SaleInfoModel>(_saleInfo);

            return(PartialView("EditSaleInfoView", saleInfo));
        }
Ejemplo n.º 4
0
        public void AddInformationToTheDb(string fileName)
        {
            AddLog("start add information");
            try
            {
                var records = new Reader(fileName).Read();

                var parser = new Parser();
                var fileInformation = parser.ParseFileName(fileName);

                using (var fileInformationRepository = new FileInformationRepository())
                {
                    fileInformationRepository.Add(fileInformation);
                    fileInformation = fileInformationRepository.FileObjectByName(fileInformation.Name);

                    using (var saleInfoRepository = new SaleInfoRepository())
                    {
                        foreach (var record in records)
                        {
                            var saleInfo = parser.ParseRecord(record);
                            saleInfo.FileInformation = fileInformation;
                            lock (Locker)
                            {
                                saleInfoRepository.Add(saleInfo);
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine("exception " + ex.Message);
                //throw;
            }
            AddLog("add infromation OK ");
        }
Ejemplo n.º 5
0
        public void AddInformationToTheDb(string fileName)
        {
            AddLog("start add information");
            try
            {
                var records = new Reader(fileName).Read();

                var parser          = new Parser();
                var fileInformation = parser.ParseFileName(fileName);

                using (var fileInformationRepository = new FileInformationRepository())
                {
                    fileInformationRepository.Add(fileInformation);
                    fileInformation = fileInformationRepository.FileObjectByName(fileInformation.Name);

                    using (var saleInfoRepository = new SaleInfoRepository())
                    {
                        foreach (var record in records)
                        {
                            var saleInfo = parser.ParseRecord(record);
                            saleInfo.FileInformation = fileInformation;
                            lock (Locker)
                            {
                                saleInfoRepository.Add(saleInfo);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("exception " + ex.Message);
                //throw;
            }
            AddLog("add infromation OK ");
        }
 public ActionResult GetSaleInfos()
 {
     var saleInfos = new SaleInfoRepository().Items.ToList();
     var res = Mapper.Map<IList<SaleInfo>, IList<SaleInfoModel>>(saleInfos);
     return PartialView("SaleInfoView", res);
 }
        public ActionResult GetManagerGraphic()
        {
            var srep = new SaleInfoRepository();
            var mrep = new ManagerRepository();

            var saleInfos = srep.Items.ToList();
            var managers = mrep.Items.ToList();
            var dict = managers.ToDictionary(manager => manager.Id, manager => 0);

            int total = saleInfos.Count;
            foreach (var saleInfo in saleInfos)
            {
                var _manager = saleInfo.FileInformation.Manager;
                try
                {
                    dict[_manager.Id]++;
                }
                catch (Exception e)
                { }
            }

            var res = new List<KeyValuePair<string, int>>();

            foreach (var entry in dict)
            {
                var manag = managers.FirstOrDefault(manager => manager.Id == entry.Key);
                res.Add(new KeyValuePair<string, int>(manag.SecondName, entry.Value));
            }
            return Json(res, JsonRequestBehavior.AllowGet);
        }
        public ActionResult EditSaleInfo(int id)
        {
            var _saleInfo = new SaleInfoRepository().SaleInfoObjectById(id);
            if (_saleInfo == null)
                return View("Error");

            var saleInfo = Mapper.Map<SaleInfoModel>(_saleInfo);
            return PartialView("EditSaleInfoView", saleInfo);
        }