예제 #1
0
        public static void Flash(
            this Controller controller, ModelStateDictionary modelState, FlashEnum type = FlashEnum.Success)
        {
            var error = new TagBuilder("ul");

            foreach (var ms in modelState)
            {
                if (ms.Value.Errors.Any())
                {
                    foreach (var err in ms.Value.Errors)
                    {
                        var li = new TagBuilder("li");
                        if (ms.Key.Trim().Length == 0)
                        {
                            li.InnerHtml.AppendHtml(string.Format("The page has the error(s): \n\n {0}", err.ErrorMessage));
                        }
                        else
                        {
                            li.InnerHtml.AppendHtml(string.Format("The property '{0}' has the error '{1}'", ms.Key, err.ErrorMessage));
                        }
                        error.InnerHtml.AppendHtml(li.ToString());
                    }
                }
            }
            controller.TempData[GetType(type)] = error.ToString();
        }
예제 #2
0
 public static void CopyTo <TModel>(
     this RulesException <TModel> ex, Controller controller, FlashEnum type = FlashEnum.Error) where TModel : class
 {
     if (ex.Errors.Count > 0)
     {
         controller.Flash(ex.Errors, type);
     }
 }
예제 #3
0
        public static void Flash(
            this Controller controller, IList <RuleViolation> ruleViolations, FlashEnum type = FlashEnum.Success)
        {
            var error = new TagBuilder("ul");

            foreach (var rv in ruleViolations)
            {
                var li = new TagBuilder("li");
                li.InnerHtml.AppendHtml(string.Format("The model has the error(s): \n\n '{0}'", rv.Message));
                error.InnerHtml.AppendHtml(li.ToString());
            }
            controller.TempData[GetType(type)] = error.ToString();
        }
예제 #4
0
 public static void Flash(this Controller controller, string message, FlashEnum type = FlashEnum.Success)
 {
     var classe = "";
     switch (type)
     {
         case FlashEnum.Success: classe = "alert-success";
             break;
         case FlashEnum.Info: classe = "alert-info";
             break;
         case FlashEnum.Warning: classe = "alert-warning";
             break;
         case FlashEnum.Error: classe = "alert-danger";
             break;
     }
     controller.TempData[classe] = message;
 }
예제 #5
0
        public static void Flash(this Controller controller, string message, FlashEnum type = FlashEnum.Success)
        {
            var classe = "";

            switch (type)
            {
            case FlashEnum.Success: classe = "alert-success";
                break;

            case FlashEnum.Info: classe = "alert-info";
                break;

            case FlashEnum.Warning: classe = "alert-warning";
                break;

            case FlashEnum.Error: classe = "alert-danger";
                break;
            }
            controller.TempData[classe] = message;
        }
예제 #6
0
 public static void Flash(this Controller controller, string message,
                          FlashEnum type = FlashEnum.Success)
 {
     controller.TempData[string.Format("flash-{0}",
                                       type.ToString().ToLower())] = message;
 }
예제 #7
0
 public static void Flash(this Controller controller, string message,
     FlashEnum type = FlashEnum.Success)
 {
     controller.TempData[string.Format("flash-{0}",
         type.ToString().ToLower())] = message;
 }
예제 #8
0
        public static void Flash(
            this Controller controller, Dictionary <string, IEnumerable <string> > modelState, FlashEnum type = FlashEnum.Success)
        {
            var error = new TagBuilder("ul");

            foreach (var key in modelState.Keys)
            {
                var li = new TagBuilder("li");
                if (modelState[key].Any())
                {
                    if (modelState[key].Count() == 1)
                    {
                        if (!string.IsNullOrEmpty(key))
                        {
                            li.InnerHtml.AppendHtml(string.Format("\t{0}: {1}", key, modelState[key].ElementAt(0)));
                        }
                        else
                        {
                            li.InnerHtml.AppendHtml(string.Format("\t{1}", key, modelState[key].ElementAt(0)));
                        }
                    }
                    else
                    {
                        foreach (var text in modelState[key])
                        {
                            li.InnerHtml.AppendHtml(string.Format("\t\t{0}\n", text));
                        }
                    }

                    error.InnerHtml.AppendHtml(li.ToString());
                }
            }
            controller.TempData[GetType(type)] = error.ToString();
        }
예제 #9
0
 public static void Flash(
     this Controller controller, string message, FlashEnum type = FlashEnum.Success)
 {
     controller.TempData[GetType(type)] = message;
 }
예제 #10
0
 private static string GetType(FlashEnum type)
 {
     return(string.Format("flash-{0}", type.ToString().ToLower()));
 }
예제 #11
0
        // Quickpast the given entry into the data control
        private void QuickPasteEntryPasteIntoDataControls(QuickPasteEntry quickPasteEntry, FlashEnum flash)
        {
            this.FilePlayer_Stop(); // In case the FilePlayer is going
            int row = this.DataHandler.ImageCache.CurrentRow;

            if (!this.DataHandler.FileDatabase.IsFileRowInRange(row))
            {
                return; // This shouldn't happen, but just in case...
            }

            foreach (QuickPasteItem item in quickPasteEntry.Items)
            {
                if (item.Use == false)
                {
                    continue;
                }

                // Find the data entry control that matches the quickPasteItem's DataLabel
                foreach (KeyValuePair <string, DataEntryControl> pair in this.DataEntryControls.ControlsByDataLabel)
                {
                    DataEntryControl control = pair.Value;
                    if (control.DataLabel == item.DataLabel)
                    {
                        // Changing a counter value does not trigger a ValueChanged event if the values are the same.
                        // which means multiple images may not be updated even if other images have the same value.
                        // To get around this, we set a bogus value and then the real value, which means that the
                        // ValueChanged event will be triggered. Inefficient, but seems to work.
                        if (this.IsDisplayingMultipleImagesInOverview() && control is DataEntryCounter counter)
                        {
                            counter.SetBogusCounterContentAndTooltip();
                        }

                        control.SetContentAndTooltip(item.Value);
                        if (flash == FlashEnum.FlashPreview)
                        {
                            control.FlashPreviewControlValue();
                        }
                        else
                        {
                            control.FlashContentControl();
                        }
                        break;
                    }
                }
            }
        }