public ActionResult New(String message) { ViewBag.Message = message; if (Functions.NoSession()) { return(RedirectToAction("Login", "Authentication")); } //check for saved FRD here byte[] file = DB_Functions.GetSaved(); if (file != null) { if (String.IsNullOrEmpty(message)) { ViewBag.Message = "Previously saved FRD data loaded successfully. To erase, click on the RESET button"; } Frd myfrd = G_Functions.DeserializeFromBytes <Frd>(file); myfrd.Type = Frd.TypesEnum.Saved; ViewBag.helpMessage = "•Panl0, Panel1 and Panel 7 are compulsory to fill, all other panels are optional. \n" + "•Save To Draft Button will quickly save the currently inserted data for subsequent use.\n" + "•Reset Button will erase the currently inserted data and the most recent draft data, if any."; return(View(SavedFrdHandling.ProcessInfo(myfrd))); } //get list of target audience from database and store in variable a List <TargetAudience> a = DB_Functions.DefaultTargets(); //get list of channels from database and store in variable b List <Channel> b = DB_Functions.DefaultChannels(); //get list of departments with their respective employees inside from database and store in //variable c List <Distribution_Groups> c = DB_Functions.DefaultGroups(); var senders = DB_Functions.DefaultSmsSenders(); var viewModel = new Frd() { Type = Frd.TypesEnum.New, Upload_Token = DB_Functions.NewUploadToken(DB_Functions.UploadTokenType.New), Panel0 = new Panel_0() { Owner = Functions.GetName() }, Panel2 = new Panel_2() { Targets = a }, Panel3 = new Panel_3() { Channels = b }, Panel4 = new Panel_4() { Senders = senders }, Panel7 = new Panel_7() { DistributionGroups = c } }; ViewBag.helpMessage = "•Panl0, Panel1 and Panel 7 are compulsory to fill, all other panels are optional. \n" + "•Save To Draft Button will quickly save the currently inserted data for subsequent use.\n" + "•Reset Button will erase the currently inserted data and the most recent draft data, if any."; return(View(viewModel)); }
public static Frd Process(Frd file, int V = 0) { string FRD_ID = file.Panel0.Id; file.Panel0.Versions = DB_Functions.ReadVersionsList(FRD_ID, V); int version; if (file.Type == Frd.TypesEnum.Closed && V == 0) { if (file.Panel0.Versions.Count > 1) { version = file.Panel0.Versions[file.Panel0.Versions.Count - 2].Number; } else { version = file.Panel0.Versions[file.Panel0.Versions.Count - 1].Number; } } else { version = file.Panel0.Versions[file.Panel0.Versions.Count - 1].Number; } file.Panel1 = new Panels.Panel_1() { Items = DB_Functions.ReadItemsAndComments(FRD_ID, version) }; file.Panel2 = new Panels.Panel_2 { Targets = DB_Functions.ReadTargetsWithDefaults(FRD_ID, version) }; file.Panel3 = new Panels.Panel_3 { Channels = DB_Functions.ReadChannelsWithDefaults(FRD_ID, version) }; file.Panel4 = new Panels.Panel_4 { Senders = DB_Functions.DefaultSmsSenders(), SMS = DB_Functions.ReadSms(FRD_ID, version, file.Panel0.Versions) }; file.Panel5 = new Panels.Panel_5 { Attatchments = DB_Functions.ReadFiles(FRD_ID, version) }; foreach (var x in file.Panel5.Attatchments) { var nn = file.Panel0.Versions.Find(z => z.Number == x.Version); x.Owner = nn.ReviserInfo.Name + " " + nn.ReviserInfo.Surname; } file.Panel6 = new Panels.Panel_6 { DiscountItems = DB_Functions.ReadDiscounts(FRD_ID, version) }; file.Panel7 = new Panels.Panel_7 { DistributionGroups = DB_Functions.ReadConfirmations(FRD_ID, version) }; DB_Functions.FrdNotisSeen(file.Panel0.Id, file.LatestVersion); return(file); }