public IActionResult Details(int Id)
        {
            SecoundrySourceService ss = new SecoundrySourceService(_Context);
            var SecondryDetails       = ss.GetSecondaryLoads(Id);

            return(View(SecondryDetails));
        }
        public async Task <IActionResult> Edit(SecoundrySouresDataModelSim obj)
        {
            SecoundrySourceService ps = new SecoundrySourceService(_Context);
            bool tr = await ps.EditSecondarySource(obj);

            return(RedirectToAction(nameof(Index)));
        }
        public IActionResult Edit(int Id)
        {
            SecoundrySourceService ps = new SecoundrySourceService(_Context);
            var sec = ps.MappingToSecoundrySourceDataModel(ps.GetSecoundrySourceFromDBByCode(Id));

            return(View(sec));
        }
        public async Task <IActionResult> Delete(int Id)
        {
            SecoundrySourceService ps = new SecoundrySourceService(_Context);
            int  P_Id    = ps.GetPrimarySourceId(Id);
            bool deleted = await ps.Delete(Id);

            return(RedirectToAction("Index"));
        }
        public IActionResult homeCreate(int Id)
        {
            FactoryService         fs = new FactoryService(_Context);
            SecoundrySourceService ss = new SecoundrySourceService(_Context);

            ViewBag.factories   = fs.GetAllFactoriesSimple();
            ViewBag.secondaries = ss.GetAllSecoundrySources();
            return(View());
        }
        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> homeCreate(SecoundrySouresDataModelSim obj)
        {
            SecoundrySourceService ss = new SecoundrySourceService(_Context);

            var y = ss.GetSecondaryByName(obj.Name, obj.PS_Id);

            if (y != null)
            {
                FactoryService fs = new FactoryService(_Context);
                ViewBag.factories = fs.GetAllFactoriesSimple();
                ModelState.AddModelError("Name", "Name is already exist");
                return(View());
            }



            bool created = await ss.CreateSecoundrySourceAsync(obj);

            return(RedirectToAction("Index"));
        }
        public IActionResult Index(int facid = -1, int primary = -1)
        {
            List <SecoundrySouresDataModelSim> allsec;
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            SecoundrySourceService ss = new SecoundrySourceService(_Context);

            if (facid != -1)
            {
                allsec = ss.GetSpecificSecondary(facid, primary);
            }
            else
            {
                allsec = ss.GetAllSecoundrySources();
            }


            return(View(allsec));
        }
        public List <secondarySource> GetAllSecondarySourcesbyfacId(int factoryid)  //type of distination
        {
            SecoundrySourceService ss = new SecoundrySourceService(_Context);

            return(ss.GetAllSecondarySourcesbyfacId(factoryid));
        }