public ActionResult Save(int id, string title, string description) { // get current logged user ApplicationUser currentUser = this.CurrentUser; if (currentUser != null) { DashboardNote dashboardNote; if (id == -1) { dashboardNote = new DashboardNote(); db.DashboardNotes.Add(dashboardNote); } else { dashboardNote = db.DashboardNotes.Find(id); } // populate the fields dashboardNote.Title = title; dashboardNote.Description = description; dashboardNote.ApplicationUser = currentUser; // update changes in database db.SaveChanges(); return(Json(dashboardNote)); } else { return(new HttpUnauthorizedResult("You are not logged in.")); } }
public ActionResult Edit([Bind(Include = "Id,Title,Description,ApplicationUserId")] DashboardNote dashboardNote) { if (ModelState.IsValid) { db.Entry(dashboardNote).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ApplicationUserId = new SelectList(db.Users, "Id", "Email", dashboardNote.ApplicationUserId); return(View(dashboardNote)); }
// GET: DashboardNotes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DashboardNote dashboardNote = db.DashboardNotes.Find(id); if (dashboardNote == null) { return(HttpNotFound()); } return(View(dashboardNote)); }
// GET: DashboardNotes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DashboardNote dashboardNote = db.DashboardNotes.Find(id); if (dashboardNote == null) { return(HttpNotFound()); } ViewBag.ApplicationUserId = new SelectList(db.Users, "Id", "Email", dashboardNote.ApplicationUserId); return(View(dashboardNote)); }
public void GetLaborDashboardViewModelSingleTest() { var now = DateTime.Now; var note = new DashboardNote { ErrorMessage = "en fehler", Message = "chaibe siäch, eifach abgstellt hetter", Code = "666" }; var info = new DashboardInfo { RwType = RwType.Better, InfoValue = "666", InfoKey = "the number of the beast" }; var po = new ProductionOrderItem { RwType = RwType.Better, Action = "action", HasNotes = true, Notes = new List <DashboardNote> { note }, ProductionOrderName = "666", Controller = "controller", SheetId = 12, DashboardInfos = new List <DashboardInfo> { info } }; var labordashboardbllmock = MockHelperBll.GetLaborDashboardBll( new List <TestSheet> { new TestSheet { MachineNr = "M10", CreatedDateTime = now } } ); var labordashboardhelpermock = MockHelperLaborDashboardHelper.GetLaborDashboardHelper( new List <DashboardNote> { note }, RwType.Better, new List <DashboardInfo> { info }, po, new List <ProductionOrderItem> { po } ); var shifthelpermock = MockHelperBll.GetShiftHelper( lastXShiftSchedules: new List <ShiftSchedule> { new ShiftSchedule { ShiftType = ShiftType.Morning, StartDay = now.DayOfWeek, EndDay = now.DayOfWeek, StartTime = now.TimeOfDay, EndTime = now.TimeOfDay }, new ShiftSchedule(), new ShiftSchedule(), new ShiftSchedule() } , shiftType: ShiftType.Morning , shiftScheduleCurrent: new ShiftSchedule { ShiftType = ShiftType.Morning, StartDay = now.DayOfWeek, EndDay = now.DayOfWeek, StartTime = now.TimeOfDay, EndTime = now.TimeOfDay } , dateExistsInShift: time => now.IsSameOrEqualTo(time) ); var target = new LaborDashboardService(new NLogLoggerFactory()) { LaborDashboardBll = labordashboardbllmock, LaborDashboardHelper = labordashboardhelpermock, ShiftHelper = shifthelpermock }; var actual = target.GetLaborDashboardViewModel(); actual.DashboardItemM10.MachineName.Should() .Be("M10"); actual.DashboardItemM11.MachineName.Should() .Be("M11"); actual.DashboardItemM49.MachineName.Should() .Be("M49"); actual.DashboardItemM10.ShiftItemsCurrent.Count.Should() .Be(1); actual.DashboardItemM10.ShiftItemsMinus1.Count.Should() .Be(1); actual.DashboardItemM10.ShiftItemsMinus2.Count.Should() .Be(1); actual.DashboardItemM10.ShiftItemsMinus3.Count.Should() .Be(1); actual.DashboardItemM11.ShiftItemsCurrent.Count.Should() .Be(0); actual.DashboardItemM11.ShiftItemsMinus1.Count.Should() .Be(0); actual.DashboardItemM11.ShiftItemsMinus2.Count.Should() .Be(0); actual.DashboardItemM11.ShiftItemsMinus3.Count.Should() .Be(0); actual.DashboardItemM49.ShiftItemsCurrent.Count.Should() .Be(0); actual.DashboardItemM49.ShiftItemsMinus1.Count.Should() .Be(0); actual.DashboardItemM49.ShiftItemsMinus2.Count.Should() .Be(0); actual.DashboardItemM49.ShiftItemsMinus3.Count.Should() .Be(0); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].RwType.Should() .Be(po.RwType); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].DashboardInfos.Count.Should() .Be(1); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].DashboardInfos.ToList()[0].Should() .Be(info); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].SheetId.Should() .Be(po.SheetId); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].Action.Should() .Be(po.Action); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].Controller.Should() .Be(po.Controller); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].HasNotes.Should() .Be(po.HasNotes); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].ProductionOrderName.Should() .Be(po.ProductionOrderName); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].Notes.Count.Should() .Be(1); actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].Notes.ToList()[0].Should() .Be(note); }