public List <InterestView> GetAllInterests() { try { using (DDS_Context dbContext = new DDS_Context()) { List <InterestView> response = new List <InterestView>(); var entity = dbContext.Interest.ToList(); if (entity != null) { foreach (var item in entity) { if (item.Id != 0) { InterestView obj = new InterestView(); obj.Id = item.Id; obj.Name = item.Name; obj.CreatedDate = Convert.ToString(item.CreatedDate); obj.UpdatedDate = Convert.ToString(item.UpdatedDate); response.Add(obj); } } } return(response); } } catch (Exception ex) { throw ex; } }
public int GetUserInterestID(int UserId) { try { using (DDS_Context dbContext = new DDS_Context()) { InterestView response = new InterestView(); var entity = dbContext.User.FirstOrDefault(x => x.Id == UserId); if (entity != null) { response.Id = entity.InterestId; } return(response.Id); } } catch (Exception ex) { throw ex; } }