Exemplo n.º 1
0
        public ActionResult DelData(PowerUsageModel model)
        {
            try
            {
                int mm  = model.month;
                int yy  = model.year;
                int cid = 0;
                if (model.CompID != null && model.CompID != 0)
                {
                    cid = Convert.ToInt32(model.CompID);
                }
                PowerUsageModel        objModel   = new PowerUsageModel();
                PowerUsageService      objService = new PowerUsageService();
                List <PowerUsageModel> objListSC  = new List <PowerUsageModel>();

                objListSC = objService.getPUDataByMMYY(mm, yy, cid);
                objModel.ListPowerData = new List <PowerUsageModel>();
                objModel.ListPowerData.AddRange(objListSC);
                foreach (var i in objModel.ListPowerData)
                {
                    int id = i.PUID;
                    objModel = objService.getByID(id);
                    Dbcontext.PowerUsageMasters.Remove(Dbcontext.PowerUsageMasters.Find(id));
                    Dbcontext.SaveChanges();
                }
                int c = objListSC.Count();
                TempData["Msg"] = c + "Record Deleted.";
            }
            catch (Exception ex)
            {
                TempData["Msg"] = "Record Not Deleted. " + ex;
                return(View("Error"));
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            PowerUsageService objService = new PowerUsageService();
            PowerUsageModel   objModel   = new PowerUsageModel();

            objModel = objService.getByID(id);

            UserService         objService1 = new UserService();
            List <CompanyModel> ListComp    = new List <CompanyModel>();

            ListComp          = objService1.getActiveComp();
            objModel.ListComp = new List <CompanyModel>();
            objModel.ListComp.AddRange(ListComp);
            return(View(objModel));
        }