public void Update(BatchView batchView, string userId) { using (var rep = new BatchRepository()) { var user = _db.Users.ToList().Find(x => x.Id == userId); Batch batch = rep.GetById(batchView.BatchTypeid); if (batch != null) { //batch.Batchid = batchView.Batchid; batch.BatchTypeid = batchView.BatchTypeid; batch.UserId = batchView.UserId; // batch.Name = user.UserProfile.FirstName; batch.BatchCode = _TypeBl.GetBatchTypeById(batchView.BatchTypeid).BatchTypeDesc.Substring(0, 2) + DateTime.Now; batch.Agerange = batchView.Agerange; batch.NumOfAnimals = batchView.NumOfAnimals; batch.Wiegth = batchView.Wiegth; batch.Totalcost = batchView.Totalcost; } // rep.Update(batch); rep.Update(ConvertBatch(batchView, userId)); } }
public ActionResult Delete(int id) { var repo = new BatchTypeRepository(); var _batchtypelog = new BatchTypeBl(); var batchview = _batchtypelog.GetBatchTypeById(id); _batchtypelog.Delete(batchview); return RedirectToAction("GetAllBatchType"); }
public List <BatchView> SearchByDescOfbatch(string searchstring) { var batchType = new BatchTypeBl(); return((from b in GetAllBatches() let cat = batchType.GetBatchTypeById(b.BatchTypeid) where cat.BatchTypeDesc.ToLower().Contains(searchstring.ToLower()) || b.BatchCode.ToLower().Contains(searchstring.ToLower()) select b).ToList()); }
private static Batch ConvertBatch(BatchView batchView, String userId) { var bty = new BatchTypeBl(); var user = _db.Users.ToList().Find(x => x.Id == userId); var batch = new Batch { Batchid = batchView.Batchid, BatchTypeid = batchView.BatchTypeid, UserId = batchView.UserId, Name = user.UserProfile.FirstName, BatchCode = bty.GetBatchTypeById(batchView.BatchTypeid).BatchTypeDesc.Substring(0, 2) + DateTime.Now, Agerange = batchView.Agerange, NumOfAnimals = batchView.NumOfAnimals, Wiegth = batchView.Wiegth, Totalcost = batchView.Totalcost }; return(batch); }
//Single Batchtype public ActionResult Details(int id) { var batchtypelog = new BatchTypeBl(); return View(batchtypelog.GetBatchTypeById(id)); }