// // GET: /Worker/Delete/5 public ActionResult Delete(int id) { var bl = new BL.Worker(); bl.Delete(id); return RedirectToAction("Index"); }
// // GET: /Worker/Details/5 public ActionResult Details(int id) { var bl = new BL.Worker(); var worker = bl.Get(id); var model = Models.WorkerModel.Create(worker.ID, worker.Name); return View( model); }
// // GET: /Worker/Edit/5 //public ActionResult Edit() //{ // var model = Models.WorkerModel.Create(0, ""); // return View(model); //} public ActionResult Edit(int? id) { var bl = new BL.Worker(); if (id.HasValue) { var worker = bl.Get(id.Value); var model = Models.WorkerModel.Create(worker.ID, worker.Name); return View(model); } else { var model = Models.WorkerModel.Create(0, string.Empty); return View(model); } }
// GET api/chunkapi/5 public Models.ChunksModel Get(int workerID) { var workerBL = new BL.Worker(); var worker = workerBL.Get(workerID); Debug.Assert( worker.ID == workerID ); var chunkBL = new BL.Chunk(); var chunks = chunkBL.GetByWorker(worker); var ret = Models.ChunksModel.Create(worker.ID, worker.Name, chunks.Select( c => Models.ChunkModel.Create( c, worker.ID )).ToList() ); return ret; }
public ActionResult Index(int id) { Debug.Assert(0 != id); var bl = new BL.Worker(); var worker = bl.Get(id); // HACK: Test data. var chunks = new List<Models.ChunkModel>() { Models.ChunkModel.Create(-1, DateTime.Now, null, new TimeSpan(0, 30, 0), id) }; var model = Models.ChunksModel.Create( id, worker.Name, chunks); return View(model); }
private void button1_Click(object sender, EventArgs e) { BL.Worker worker = new BL.Worker(); if (!(txtname.Text.Equals("") || txtOriginalPrice.Text.Equals("") || txtsellPrice.Text.Equals("") || txtCriticalQuantity.Text.Equals("") || txtAvilableQuantiity.Text.Equals(""))) { BL.Product product=new BL.Product(txtname.Text,Convert.ToInt32(txtAvilableQuantiity.Text),Convert.ToInt32(txtCriticalQuantity.Text),float.Parse(txtOriginalPrice.Text),float.Parse(txtsellPrice.Text)); if(worker.AddProduct(product)){ // check product is added if added show user message box Done MessageBox.Show("تم اضافة المنج بنجاح"); txtAvilableQuantiity.Text = ""; txtCriticalQuantity.Text = ""; txtname.Text = ""; txtOriginalPrice.Text = ""; txtsellPrice.Text = ""; } else{ // if prduct do not adde show user message Wrong for adding product MessageBox.Show("خطا فى الاضافه"); } } else { MessageBox.Show("املا جميع الفرغات"); } //show message box to make user write all fields }
static void Main(string[] args) { var repositoryBL = new BL.Repository(); repositoryBL.Setup(); var workerBL = new BL.Worker(); Console.WriteLine("Adding new worker."); var newWorker = workerBL.AddWorker("My new worker " + DateTime.Now.ToShortTimeString()); Console.WriteLine(string.Format("New Worker id={0}, name={1}.", newWorker.ID, newWorker.Name)); Console.WriteLine("Getting the newly created worker."); var worker = workerBL.Get(newWorker.ID); Console.WriteLine("The worker's name={0}.", worker.Name); Console.WriteLine("Getting all workers."); var workerList = workerBL.GetAll(); foreach (var w in workerList) { Console.WriteLine(string.Format( "ID:{0},Name:{1}", w.ID, w.Name)); } Console.WriteLine("Updating the newly created worker."); worker.Name = "New worker [" + DateTime.Now.ToShortTimeString() + "]"; var updatedWorker = workerBL.Update( worker ); Console.WriteLine("Worker updated with name = " + worker.Name + " resulted in " + updatedWorker.Name); Console.WriteLine("Deleting the node again."); workerBL.Delete(worker.ID); workerList = workerBL.GetAll(); foreach (var w in workerList) { Console.WriteLine(string.Format("ID:{0},Name:{1}", w.ID, w.Name)); } ManipulateChunk(workerList.First()); Console.WriteLine(); Console.Write("Press any key..."); Console.ReadKey(); }
public ActionResult Index() { ViewBag.Message = "Workers work."; var bl = new BL.Worker(); var lst = bl.GetAll(); var model = new Models.WorkersModel(); model.WorkerList = lst.Select(x => Models.WorkerModel.Create(x.ID, x.Name)).ToList(); return View(model); }
public ActionResult Edit(Models.WorkerModel model) { var bl = new BL.Worker(); if (model.ID == 0) { var worker = bl.AddWorker(model.Name); model.Set(worker); return View("Details", model); } else { var worker = bl.Get(model.ID); worker.Set(model.Name); bl.Update(worker); model.Set(worker); return View("Details", model); } }
private void Window_Loaded_1(object sender, RoutedEventArgs e) { var workerBL = new BL.Worker(); var workers = workerBL.GetAll(); DataContext = workers; }