public IActionResult Record(Models.o53RecordViewModel v) { if (ModelState.IsValid) { BO.o53TagGroup c = new BO.o53TagGroup(); if (v.Rec.pid > 0) { c = Factory.o53TagGroupBL.Load(v.Rec.pid); } c.o53Name = v.Rec.o53Name; var prefixes = new List <string>(); foreach (var x in v.SelectedEntities.Where(p => p > 0)) { prefixes.Add(BL.TheEntities.ByIntPrefix(x).Prefix); } c.o53Entities = String.Join(",", prefixes); c.o53IsMultiSelect = v.Rec.o53IsMultiSelect; c.o53Ordinary = v.Rec.o53Ordinary; c.ValidUntil = v.Toolbar.GetValidUntil(c); c.ValidFrom = v.Toolbar.GetValidFrom(c); v.Rec.pid = Factory.o53TagGroupBL.Save(c); if (v.Rec.pid > 0) { _cp.Refresh(); //obnovit názvy sloupců kategorií v.SetJavascript_CallOnLoad(v.Rec.pid); return(View(v)); } } v.Toolbar = new MyToolbarViewModel(v.Rec); v.ApplicableEntities = GetApplicableEntities(); this.Notify_RecNotSaved(); return(View(v)); }
public int Save(BO.o53TagGroup rec) { if (String.IsNullOrEmpty(rec.o53Entities) == true) { _mother.CurrentUser.AddMessage("Chybí vazba na entity."); return(0); } var p = new DL.Params4Dapper(); if (rec.o53Field == null)//najít volné pole pro grid { var lis = GetList(new BO.myQuery("o53TagGroup")).Where(p => p.o53Field != null).OrderByDescending(p => p.o53Field); int intFieldIndex = 1; if (lis.Count() > 0) { intFieldIndex = 1 + Convert.ToInt32(BO.BAS.RightString(lis.First().o53Field, 2)); } rec.o53Field = "o54Group" + BO.BAS.RightString("0" + intFieldIndex.ToString(), 2); } p.AddInt("pid", rec.o53ID); p.AddString("o53Name", rec.o53Name); if (rec.j02ID_Owner == 0) { rec.j02ID_Owner = _db.CurrentUser.j02ID; } p.AddInt("j02ID_Owner", rec.j02ID_Owner, true); p.AddString("o53Entities", rec.o53Entities); p.AddInt("o53Ordinary", rec.o53Ordinary); p.AddBool("o53IsMultiSelect", rec.o53IsMultiSelect); p.AddString("o53Field", rec.o53Field); return(_db.SaveRecord("o53TagGroup", p.getDynamicDapperPars(), rec)); }