Esempio n. 1
0
 public ActionResult Index(RawItemMasterViewModel RIMViewModel, string value)
 {   // Search
     RIMViewModel                   = RawItemMasterManager.SearchSingleRawItem(value);
     RIMViewModel.HasSearched       = true;
     RIMViewModel.RawItemMasterList = RawItemMasterManager.GetRawItems("ALL");
     return(View(RIMViewModel));
 }
Esempio n. 2
0
        /*
         * Default method.
         * TempData is used to store the ViewModel after a Search action.
         */
        public ActionResult Index(string id)
        {
            // Validate log in and user access
            UserAccessSession UASession = (UserAccessSession)Session["UserAccess"];

            if (UASession == null || !UASession.RIM)
            {
                return(RedirectToAction("Login", "Account"));
            }
            // Set NavBar Links accordingly
            Session["CurrentPage"] = new CurrentPageSession("RIM", "HOME", "LOG");

            // SearchItemSelected is assigned value at DisplaySearchResult
            RawItemMasterViewModel RIMViewModel = new RawItemMasterViewModel();

            if (id != null)
            {
                RIMViewModel = RawItemMasterManager.SearchSingleRawItem(id);
            }
            RIMViewModel.RawItemMasterList = RawItemMasterManager.GetRawItems("ALL");
            return(View(RIMViewModel));
        }
Esempio n. 3
0
        public ActionResult UpdateDelete(RawItemMasterViewModel RIMViewModel, string command)
        {
            UserSession user       = (UserSession)Session["User"];
            string      PageAction = "";
            bool        result     = false;

            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files["FileUploaded"];
                if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))
                {
                    ReportViewModel report = RawItemMasterManager.ImportExcel(file.InputStream, user.Username);
                    PageAction = "Import";
                    result     = report.Result;
                    if (!result)
                    {
                        if (report.ErrorLevel == 2)
                        {
                            PageAction = report.Message + ": Import partially";
                        }
                        else
                        {
                            PageAction = report.Message + ": Import";
                        }
                    }
                    else
                    {
                        PageAction = report.Message + ": Import";
                    }
                }
            }
            if (command == null && !(RIMViewModel.SwitchItem == null))
            {
                result     = RawItemMasterManager.SwitchRawItem(RIMViewModel.RIMRIC, RIMViewModel.SwitchItem, user.Username);
                PageAction = "Switch";
            }
            if (command == "Save")
            {
                result     = RawItemMasterManager.UpdateRawItem(RIMViewModel, user.Username);
                PageAction = "Update";
                if (!RIMViewModel.HasSearched)
                {
                    PageAction = "Create";
                }
            }
            else if (command == "Delete")
            {
                result     = RawItemMasterManager.DeleteRawItem(RIMViewModel);
                PageAction = "Delete";
            }
            if (result)
            {
                TempData["SuccessMessage"] = PageAction + " successful";
                if (PageAction.Equals("Switch") || PageAction.Equals("Update") || PageAction.Equals("Create"))
                {
                    new AuditLogManager().Audit(user.Username, DateTime.Now, "Raw Item Master", PageAction, RIMViewModel.RIMRIC, RIMViewModel.RIMRID);
                }
                if (RIMViewModel.RIMRIC != null && !RIMViewModel.RIMRIC.Equals("") && !PageAction.Equals("Delete"))
                {
                    return(RedirectToAction("Index", new { id = RIMViewModel.RIMRIC }));
                }
            }
            else
            {
                TempData["ErrorMessage"] = PageAction + " failed";
            }
            return(RedirectToAction("Index"));
        }