コード例 #1
0
        public JsonResult ViewMaintanenceList(int id, int maintId)
        {
            var obj = new MaintenanceByIdRepo();
            List <AssetMaintenanceDetailDto> model = obj.getAssetMaintenanceDetail(id, maintId);

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult BindMaintenanceDetail(int id, int mainId, int statusId)
        {
            var obj       = new MaintenanceByIdRepo();
            var statusLst = new MaintenanceByStatusRepo().getMaintenanceByStatusCount();

            var schduledAndCompletedStatusId = new int[] { 3, 5 };
            AssetMaintenanceDetailDto model  = obj.getAssetMaintenanceDetailbyID(id, mainId);

            if (model.Category.ToLower() == "Maintenance".ToLower() || model.Category.ToLower() == "UNPLANNED MAINTENANCE".ToLower())
            {
                ViewBag.lstStatus = statusLst.Where(x => x.MaintStatusId == 3);
            }
            else if (statusId == 1 || statusId == 2 || statusId == 5)
            {
                ViewBag.lstStatus = statusLst.Where(x => schduledAndCompletedStatusId.Contains(x.MaintStatusId));
            }
            else if (statusId == 3)
            {
                ViewBag.lstStatus = statusLst.Where(x => x.MaintStatusId == 5);
            }
            else if (statusId == 7)
            {
                ViewBag.lstStatus = statusLst.Where(x => x.MaintStatusId == 6);
            }

            var filePaths = Directory.GetFiles(Server.MapPath("/Uploaded_File"))
                            .Where(f => Path.GetFileNameWithoutExtension(f).ToLower() == model.URI.ToString().ToLower()).Select(f => Path.GetFileName(f));

            if (TempData["CostPartDetails"] != null)
            {
                TempData.Remove("CostPartDetails");
            }

            TempData["CostPartDetails"] = model.lstParts;
            TempData.Keep("CostPartDetails");

            if (filePaths.Count() > 0)
            {
                model.FileName = "~/Uploaded_File/" + filePaths.FirstOrDefault();
            }
            return(View(model));
        }
コード例 #3
0
        public JsonResult InsertMaintenance(AssetMaintenanceDetailDto asstMaint)
        {
            var obj = new MaintenanceByIdRepo();

            asstMaint.lstParts = TempData.Peek("CostPartDetails") as List <lstPartDetails>;

            var statusLst = obj.insertMaintenance(asstMaint);

            if (string.IsNullOrEmpty(statusLst))
            {
                return(Json("Error occured. Please try again after some time."));
            }

            if (Request.Files.Count > 0)
            {
                var uploadFiles = Request.Files[0];
                //Save File
                var fileContent = Request.Files[0];
                if (fileContent != null && fileContent.ContentLength > 0)
                {
                    // get a stream
                    var stream = fileContent.InputStream;
                    // and optionally write the file to disk
                    var fileName = statusLst + Path.GetExtension(fileContent.FileName);
                    var path     = Path.Combine(Server.MapPath("~/Uploaded_File"), fileName);

                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }

                    fileContent.SaveAs(path);
                }
            }
            return(Json("Record saved successfully."));
        }