Ejemplo n.º 1
0
        public IActionResult Edit(int Id)
        {
            PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);
            var prim = ps.MappingToPrimarySourceDataModel(ps.GetPrimarySourceFromDB(Id));

            return(View(prim));
        }
Ejemplo n.º 2
0
        public IActionResult Details(int Id)
        {
            PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);
            var ViewModel           = ps.GetPrimarySourceWithAllData(Id);

            return(View(ViewModel));
        }
Ejemplo n.º 3
0
        /*  [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));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(PrimarySourceDataModel obj)
        {
            PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);

            bool tr = await ps.EditPrimarySource(obj);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 5
0
        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 }*/));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        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"));
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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"));
            }
        }
Ejemplo n.º 10
0
        //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));
        }
Ejemplo n.º 11
0
        public List <PrimarySource> GetprimarySourcebyfacid(int factoryid)  //type of distination
        {
            PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);

            return(ps.GetprimarySourcebyfacid(factoryid));
        }