public IActionResult Edit(int Id) { PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); var prim = ps.MappingToPrimarySourceDataModel(ps.GetPrimarySourceFromDB(Id)); return(View(prim)); }
public IActionResult Details(int Id) { PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); var ViewModel = ps.GetPrimarySourceWithAllData(Id); return(View(ViewModel)); }
/* [HttpGet] * public IActionResult PeakPerDay() * { * FactoryService fs = new FactoryService(_Context); * ViewBag.factories = fs.GetAllFactoriesSimple(); * PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); * ViewBag.Primary = ps.GetAllPrimarySources(); * LoadsServices ls = new LoadsServices(_Context); * ViewBag.Loads = ls.GetAllLoads(); * return View(); * } * [HttpPost]*/ public IActionResult PeakPerDay(DateTime date, int type = -1, int primId = -1, int loadId = -1) { FactoryService fs = new FactoryService(_Context); ViewBag.factories = fs.GetAllFactoriesSimple(); PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); ViewBag.Primary = ps.GetAllPrimarySources(); LoadsServices ls = new LoadsServices(_Context); ViewBag.Loads = ls.GetAllLoads(); ReportService rs = new ReportService(_Context); PowerPeakViewModel res = new PowerPeakViewModel(); if (type == 1) { res = rs.PowerPeakPerDay(date, type, primId); } else { res = rs.PowerPeakPerDay(date, type, loadId); } return(View(res)); }
public async Task <IActionResult> Edit(PrimarySourceDataModel obj) { PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); bool tr = await ps.EditPrimarySource(obj); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Delete(int?Id) { PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); int FacId = ps.GetFactoryId(Id); bool deleted = await ps.Delete(Id); return(RedirectToAction("index" /* , new { Id = FacId }*/)); }
public IActionResult Status() { ReportService rs = new ReportService(_con); PrimarySourceSerivce ps = new PrimarySourceSerivce(_con); SecoundrySourceService ss = new SecoundrySourceService(_con); ViewBag.primaries = ps.GetAllPrimarySources(); ViewBag.secondaries = ss.GetAllSecoundrySources(); var model = rs.GetSourceStatus(); return(View(model)); }
public async Task <IActionResult> Create(PrimarySourceDataModel obj) { PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); var y = ps.GetPrimaryByName(obj.Name, obj.FacId); if (y != null) { FactoryService fs = new FactoryService(_Context); ViewBag.factories = fs.GetAllFactoriesSimple(); ModelState.AddModelError("Name", "Name is already exist"); return(View("homeCreate", obj)); } bool created = await ps.CreatePrimarySourceAsync(obj); return(RedirectToAction("Index", "PrimarySource")); }
public IActionResult Index(int Id = -1) { PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); List <PrimarySourceDataModel> Model = null; FactoryService fs = new FactoryService(_Context); ViewBag.factories = fs.GetAllFactoriesSimple(); if (Id != -1) { Model = ps.GetAllPrimarySourcesbyfacId(Id); } else { Model = ps.GetAllPrimarySources(); } return(View(Model)); }
public IActionResult Create(int Id) { if (Id != -1) { PrimarySourceDataModel viewModel = new PrimarySourceDataModel() { FacId = Id }; return(View(viewModel)); } else { FactoryService fs = new FactoryService(_Context); PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); ViewBag.factories = fs.GetAllFactoriesSimple(); ViewBag.primaries = ps.GetAllPrimarySources(); return(View("homeCreate")); } }
//ABDO public IActionResult powerpeak(int primId, int loadId, int type = -1) //type 1 -> prim , 2 -> load { ReportService rs = new ReportService(_Context); PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); ViewBag.Primary = ps.GetAllPrimarySources(); LoadsServices ls = new LoadsServices(_Context); ViewBag.loads = ls.GetAllLoads(); PowerPeakViewModel res = new PowerPeakViewModel(); if (type == 1) { res = rs.PowerPeakBySourceID(primId, type); } else if (type == 2) { res = rs.PowerPeakBySourceID(loadId, type); } return(View(res)); }
public List <PrimarySource> GetprimarySourcebyfacid(int factoryid) //type of distination { PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context); return(ps.GetprimarySourcebyfacid(factoryid)); }