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; }
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); }
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; }
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); }
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; }
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); }