public static string Resolve(LogBook logBook, Func<IPrincipal> getUser) { if (logBook.Visibility == Visibility.PublicAnonymous && logBook.IsOwnedBy(getUser().Identity.Name) == false) return null; return logBook.OwnerId; }
public ActionResult Index() { var logbook = new LogBook { Description = "Any Old Description", OwnerId = "66", Tags = new List<string> { "any", "old", "logbook" }, Title = "Any Old Logbook", Units = new Units { Symbol = "£", Precision = 2, SymbolPosition = SymbolPosition.Before }, Visibility = Visibility.PublicAnonymous }; logbook.AddEntry(new Entry { OccurredOn = DateTime.UtcNow.AddDays(-10), Value = 10 }); logbook.AddEntry(new Entry { OccurredOn = DateTime.UtcNow.AddDays(-5), Value = 5 }); logbook.AddEntry(new Entry { OccurredOn = DateTime.UtcNow.AddDays(0), Value = 0 }); return View(); }
// POST /Api/v1/LogBooks public HttpResponseMessage Post(LogBookInput logBookInput) { if (ModelState.IsValid == false) return BadRequest(ModelState.FirstErrorMessage()); var logBook = new LogBook() { OwnerId = base.User.Identity.Name }; logBookInput.MapToInstance(logBook); base.RavenSession.Store(logBook); var logBookView = logBook.MapTo<LogBookView>(); return Created(logBookView); }