Ejemplo n.º 1
0
        public async Task <IActionResult> PutGuestBook([FromRoute] int id, [FromBody] GuestBook guestBook)
        {
            try
            {
                if (id != guestBook.gID)
                {
                    return(BadRequest());
                }
                bool flag = await guestBookService.Update(guestBook);

                return(Ok(new
                {
                    success = flag
                }));
            }
            catch (Exception ex)
            {
                loggerHelper.Error("GuestBooksController.PutGuestBook", "异常位置:GuestBooksController.PutGuestBook" + "异常消息:" + ex.Message);
                return(Ok(new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public ActionResult EditEntry(int id, gestbookentry guest)
        {
            try
            {
                var dbguest = g.FindById(id);
                dbguest.rating = guest.rating;
                dbguest.text   = guest.text;
                g.Update(dbguest);
                g.Commit();

                return(Redirect("GetAllEntries"));
            }
            catch
            {
                return(View());
            }
        }