コード例 #1
0
        public ActionResult RuleSpecDelete(long loadRuleSpecId)
        {
            MT_LOAD_RULE_SPEC deletedRuleSpec = repository.DeleteLoadRuleSpec(loadRuleSpecId);

            if (deletedRuleSpec != null)
            {
                TempData["message"] = string.Format("{0} был удален", deletedRuleSpec.LoadRuleSpecId);
            }
            return(RedirectToAction("RulesSpec"));
        }
コード例 #2
0
        public MT_LOAD_RULE_SPEC DeleteLoadRuleSpec(long loadRuleSpecId)
        {
            MT_LOAD_RULE_SPEC dbEntry = context.MT_LOAD_RULE_SPEC.Where(x => x.LoadRuleSpecId == loadRuleSpecId).Single();

            if (dbEntry != null)
            {
                context.MT_LOAD_RULE_SPEC.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
コード例 #3
0
        public ViewResult RuleSpecEdit(long loadRuleSpecId)
        {
            MT_LOAD_RULE_SPEC          loadRuleSpec = repository.LoadRulesSpec.Where(x => x.LoadRuleSpecId == loadRuleSpecId).FirstOrDefault();
            IEnumerable <MT_LOAD_RULE> loadRules    = repository.LoadRules;

            var ruleSpecVM = new RuleSpecViewModel
            {
                LoadRuleSpec = loadRuleSpec,
                LoadRules    = loadRules
            };

            return(View(ruleSpecVM));
        }
コード例 #4
0
 public void SaveLoadRuleSpec(MT_LOAD_RULE_SPEC loadRuleSpec, out string err)
 {
     err = string.Empty;
     try
     {
         loadRuleSpec.DateLoad = DateTime.Now;
         if (loadRuleSpec.LoadRuleSpecId == 0)
         {
             context.MT_LOAD_RULE_SPEC.Add(loadRuleSpec);
         }
         else
         {
             MT_LOAD_RULE_SPEC dbEntry = context.MT_LOAD_RULE_SPEC.Where(x => x.LoadRuleSpecId == loadRuleSpec.LoadRuleSpecId).Single();
             if (dbEntry != null)
             {
                 if (loadRuleSpec.Data != null &&
                     loadRuleSpec.MimeType != null &&
                     loadRuleSpec.FileName != null)
                 {
                     dbEntry.Data     = loadRuleSpec.Data;
                     dbEntry.MimeType = loadRuleSpec.MimeType;
                     dbEntry.FileName = loadRuleSpec.FileName;
                     dbEntry.Size     = loadRuleSpec.Size;
                 }
                 dbEntry.LoadRuleId = loadRuleSpec.LoadRuleId;
                 dbEntry.PathToFile = loadRuleSpec.PathToFile;
                 dbEntry.IsMain     = loadRuleSpec.IsMain;
                 dbEntry.DateLoad   = loadRuleSpec.DateLoad;
             }
         }
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         if (ex.InnerException != null && ex.InnerException.InnerException != null)
         {
             err = ex.InnerException.InnerException.Message;
         }
         else if (ex.InnerException != null)
         {
             err = ex.InnerException.Message;
         }
         else
         {
             err = ex.Message;
         }
     }
 }
コード例 #5
0
        public ActionResult DownLoadFile(long loadRuleSpecId)
        {
            MT_LOAD_RULE_SPEC          loadRuleSpec = repository.LoadRulesSpec.Where(x => x.LoadRuleSpecId == loadRuleSpecId).FirstOrDefault();
            IEnumerable <MT_LOAD_RULE> loadRules    = repository.LoadRules;

            var ruleSpecVM = new RuleSpecViewModel
            {
                LoadRuleSpec = loadRuleSpec,
                LoadRules    = loadRules
            };

            if (ruleSpecVM != null &&
                ruleSpecVM.LoadRuleSpec != null &&
                ruleSpecVM.LoadRuleSpec.Data != null &&
                ruleSpecVM.LoadRuleSpec.MimeType != null)
            {
                return(File(ruleSpecVM.LoadRuleSpec.Data, ruleSpecVM.LoadRuleSpec.MimeType, ruleSpecVM.LoadRuleSpec.FileName));
            }

            return(View("RuleSpecEdit", ruleSpecVM));
        }