예제 #1
0
        public static MvcHtmlString StatusBar(this HtmlHelper html, StatusBarInfo statusBarInfo) 
        {
            if (statusBarInfo == null || String.IsNullOrWhiteSpace(statusBarInfo.Message))
                return MvcHtmlString.Empty;

            TagBuilder statusBar = new TagBuilder("div");

            statusBar.MergeAttributes(new Dictionary<string, string> 
            { 
                {"id", "status-bar"},
                {"class", statusBarInfo.CssClasses},
                {"style", "position:fixed;bottom:0;left:0;right:0;margin:0;z-index:9999999"}
            });

            statusBar.SetInnerText(statusBarInfo.Message);

            return MvcHtmlString.Create(statusBar.ToString());
        }
예제 #2
0
        public async Task<ActionResult> DeleteConfirmed(int? id)
        {
            if (id == null)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            if (_noteService.RemoveNoteById(id.Value))
            {
                await _noteService.CommitAsync();
                TempData["StatusBarInfo"] = new StatusBarInfo
                {
                    Message = "Successfully deleted.",
                    Type = StatusBarInfo.StatusBarType.Success
                };
            }
            else 
            {
                TempData["StatusBarInfo"] = new StatusBarInfo
                {
                    Message = "Unauthorized actions detected.",
                    Type = StatusBarInfo.StatusBarType.Warning
                };
            }

            return RedirectToAction("Index");
        }
예제 #3
0
        public async Task<ActionResult> Create(NoteViewModel noteViewModel)
        {
            if (ModelState.IsValid)
            {
                Note note = Mapper.Map<NoteViewModel, Note>(noteViewModel);
                _noteService.AddNote(note);
                await _noteService.CommitAsync();
                TempData["StatusBarInfo"] = new StatusBarInfo
                {
                    Message = "Successfully created.",
                    Type = StatusBarInfo.StatusBarType.Success
                };

                return RedirectToAction("Index");
            }

            return View(noteViewModel);
        }
예제 #4
0
        public async Task<ActionResult> Edit(NoteViewModel noteViewModel)
        {
            if (ModelState.IsValid)
            {
                Note note = Mapper.Map<NoteViewModel, Note>(noteViewModel);

                if (_noteService.UpdateNote(note))
                {
                    await _noteService.CommitAsync();
                    TempData["StatusBarInfo"] = new StatusBarInfo
                    {
                        Message = "Successfully updated.",
                        Type = StatusBarInfo.StatusBarType.Success
                    };
                }
                else 
                {
                    TempData["StatusBarInfo"] = new StatusBarInfo
                    {
                        Message = "Unauthorized actions detected.",
                        Type = StatusBarInfo.StatusBarType.Warning
                    };
                }

                return RedirectToAction("Index");
            }

            return View(noteViewModel);
        }