Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
        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);
        }