public IActionResult SubscribeChannel([FromBody] tblChannelSubscribe model) { try { tblChannelSubscribe _tblChannelSubscribe = _ItblChannelSubscribeRepository.Get(x => x.FKChannel == model.FKChannel && x.FKUser == model.FKUser && x.IsActive == true).FirstOrDefault(); if (_tblChannelSubscribe == null) { model.IsActive = true; model.CreatedBy = Convert.ToString(model.FKUser); model.CreatedDate = DateTime.Now; _ItblChannelSubscribeRepository.Add(model); } else { _tblChannelSubscribe.IsActive = false; _tblChannelSubscribe.ModifiedBy = Convert.ToString(model.FKUser); _tblChannelSubscribe.ModifiedDate = DateTime.Now; _ItblChannelSubscribeRepository.Update(_tblChannelSubscribe); model = _tblChannelSubscribe; } return(Ok(model)); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public bool IsSubscribeChannel(int?PKChannel = 0, int?PKUser = 0) { try { bool isSubscribe = false; tblChannelSubscribe _tblChannelSubscribe = _ItblChannelSubscribeRepository.Get(x => x.FKUser == PKUser && x.FKChannel == PKUser && x.IsActive == true).FirstOrDefault(); if (_tblChannelSubscribe != null) { isSubscribe = true; } return(isSubscribe); } catch (Exception ex) { log.Fatal("IsSubscribeChannel", ex); throw ex; } }