public void ObserveCharity(int userId, int charityId) { var exists = _context.Users_Charities.Any(x => x.UserId == userId && x.CharityId == charityId); if (exists) { return; } var observedCharity = new User_Charity() { CharityId = charityId, UserId = userId }; _context.Users_Charities.Add(observedCharity); _context.SaveChanges(); }
public User Add(SignUpInputModel inputModel) { if (Exists(inputModel.EmailAddress)) { return(null); } var user = mapper.Map <SignUpInputModel, User>(inputModel); context.Users.Add(user); context.SaveChanges(); return(user); }
public int Add(CharityEventInputModel inputModel) { var charityEvent = _mapper.Map <CharityEventInputModel, CharityEvent>(inputModel); charityEvent.CreatedDate = DateTime.Now; _context.CharityEvents.Add(charityEvent); _context.SaveChanges(); return(charityEvent.Id); }