public void Test_Update() { WatchListBLL tbll = new WatchListBLL(_unit); var w = tbll.GetByID(1); w.IsSystem = true; tbll.Update(w); }
public async Task <IHttpActionResult> Get(int id) { WatchList w = null; try { WatchListBLL bll = new WatchListBLL(_unit); w = bll.GetByID(id); } catch (Exception ex) { LogHelper.Error(_log, ex.ToString()); return(InternalServerError(ex)); } return(Ok(w)); }
public async Task <IHttpActionResult> Delete(int id) { try { var currentUser = await GetCurrentUser(); WatchListBLL bll = new WatchListBLL(_unit); bool isAdmin = await AppUserManager.IsInRoleAsync(currentUser.Id, "Admin"); if (isAdmin) { bll.Delete(id); } else { var w = bll.GetByID(id); if (!w.IsSystem && w.Owner == currentUser.Id) { bll.Delete(id); } else { BadRequest("You don't have permission to delete this watch list."); } } } catch (Exception ex) { LogHelper.Error(_log, ex.ToString()); return(InternalServerError(ex)); } return(Ok()); }