public void Delete(int id) { var poll = new PollDa(databasecontext); if (id > 0) { var currentPoll = GetById(id); poll.Delete(currentPoll); } }
public Poll Save(int Id, string Title, int PollType, DateTime StartDate, DateTime EndDate, bool Closed) { var poll = Id > 0 ? GetById(Id) : new Poll(); poll.Title = Title; poll.PollType = PollType; poll.StartDate = StartDate; poll.EndDate = EndDate; poll.Closed = Closed; var pollDa = new PollDa(databasecontext); //if new if (Id < 1) poll = pollDa.Add(poll); //update else poll= pollDa.Update(poll); return poll; }