コード例 #1
0
ファイル: DBOperations.cs プロジェクト: VishnyakovD/workers
        public LongWorkerModel CreateWorker(LongWorkerModel worker)
        {
            db.Run(dba =>
            {
                var workerDB = dba.GetRepository<Worker>().Add(new Worker(){growth = worker.growth, name = worker.name,weight = worker.weight, position = worker.position});
                worker.idWorker = workerDB.id;

            });
            return worker;
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: VishnyakovD/workers
        public ActionResult CreateBonus(Bonus bonus,long workerId)
        {
            var model = new LongWorkerModel();
            try
            {
                model = dbOperations.AddBonus(bonus, workerId);
            }
            catch (Exception err)
            {
              //  ViewBag.Error = err.Message;
            }

            return PartialView("WorkerPartial",model);
        }
コード例 #3
0
ファイル: DBOperations.cs プロジェクト: VishnyakovD/workers
        public LongWorkerModel OneLongWorker(long workerId)
        {
            var longWorker = new LongWorkerModel();

            db.Run(dba =>
            {
                var worker = dba.GetRepository<Worker>().One(workerId);
                if (worker!=null)
                {
                    longWorker = new LongWorkerModel() { idWorker = worker.id, name = worker.name, growth = worker.growth, weight = worker.weight, position = worker.position, listBonus = worker.listBonus.OrderByDescending(b=>b.date).Take(6).ToList() };
                }

            });
            return longWorker;
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: VishnyakovD/workers
        public ActionResult CreateOrUpdateWorker(LongWorkerModel worker)
        {
            var model = new List<ShortWorkerModel>();
            try
            {
                if (worker!=null&&worker.idWorker<1)
                {
                    dbOperations.CreateWorker(worker);
                }
                else
                {
                    dbOperations.UpdateWorker(worker);
                }
                model = dbOperations.AllShortWorkers();
            }
            catch (Exception err)
            {
               // ViewBag.Error = err.Message;
            }

            return PartialView("ListWorkersPartial",model);
        }
コード例 #5
0
ファイル: DBOperations.cs プロジェクト: VishnyakovD/workers
        public LongWorkerModel UpdateWorker(LongWorkerModel worker)
        {
            db.Run(dba =>
            {
                var workerDB = dba.GetRepository<Worker>().One(worker.idWorker);
                if (workerDB != null)
                {
                    workerDB.name = worker.name;
                    workerDB.growth = worker.growth;
                    workerDB.weight = worker.weight;
                    workerDB.position = worker.position;
                    dba.GetRepository<Worker>().Update(workerDB);
                }

            });
            return worker;
        }
コード例 #6
0
ファイル: HomeController.cs プロジェクト: VishnyakovD/workers
        public ActionResult ShowWorker(long workerId)
        {
            var model = new LongWorkerModel();
            try
            {
                model = dbOperations.OneLongWorker(workerId);
            }
            catch (Exception err)
            {
                ViewBag.Error = err.Message;
            }

            return PartialView("WorkerPartial",model);
        }