/*Function which add a new payment for a conference. * IN:Participant,paidSum from form * Out:New Payment with current date,nrTickets,success of transaction * Condition:Participant is normal user */ public void addPayment(Participant participant, int nrTickets, Model.Conference conference) { if (nrTickets == 0) { throw new Exception("No tickets selected"); } else if (participant.IsNormalUser) { int conferenceId = participant.ConferenceId; RepoConference repo = new RepoConference(_context); double priceTicketForConference = conference.AdmissionPrice; double paidSum = 0; if (priceTicketForConference != 0) { paidSum = nrTickets * priceTicketForConference; } else { throw new Exception("You can participate for free.Enjoy!"); } DateTime PaymentDate = DateTime.Now; bool SuccessfulTransaction = true; Model.Payment payment = new Model.Payment(10, paidSum, nrTickets, PaymentDate, SuccessfulTransaction, participant); Payment payment1 = new Payment(); payment1.PaymentId = payment.Id; payment1.PaymentDate = payment.PaymentDate; payment1.NrOfTickets = payment.NrOfTickets; payment1.PaidSum = payment.PaidSum; payment1.SuccessfulTransaction = payment.SuccessfulTransaction; _context.Payments.Add(payment1); _context.SaveChanges(); ConferenceParticipant confP = new ConferenceParticipant(); //daca a facut plata devine un participant la conferinta. if (_context.ConferenceParticipants.Find(payment.Buyer.User.IdUser, conference.Id, payment1.PaymentId) == null) { confP.UserId = participant.User.IdUser; confP.ConferenceId = conference.Id; confP.PaymentId = payment1.PaymentId; _context.ConferenceParticipants.Add(confP); _context.SaveChanges(); } } }
public void updateConference(Model.Conference c) { Conference conference = _context.Conferences.Find(c.Id); if (conference == null) { return; } conference.DeadlineAbstractPaper = c.DeadlineAbstract; conference.DeadlineBiddingPaper = c.DeadlineBidding; conference.DeadlineCompletePaper = c.DeadlineComplet; conference.DeadlineEvaluation = c.DeadlineEvaluation; conference.DeadlineParticipation = c.DeadlineParticipation; conference.BeginDate = c.BeginDate; conference.EndDate = c.EndDate; _context.SaveChanges(); }
public List <Model.Conference> getConferences() { List <Model.Conference> all = new List <Model.Conference>(); foreach (var c in _context.getConferences) { List <string> topics = new List <string>(); foreach (var t in _context.getTopicsFor1Conference(c.ConferenceId)) { topics.Add(t.TopicName); } Model.Conference conf = new Model.Conference(c.ConferenceId, c.Name, c.Edition, topics, c.DeadlineAbstractPaper, c.DeadlineCompletePaper, c.DeadlineBiddingPaper, c.DeadlineEvaluation, c.DeadlineParticipation, c.City, c.Country, c.Website, c.Price, c.BeginDate, c.EndDate); all.Add(conf); } return(all); }
/*Function which adds a new conference. * In:Conference details * Out: returneaza id-u conferintei * new conference in the list * Conditions which are checked in repository: * DeadlineAbstract < DeadlineComplet < DeadlineParticipation < DeadlineBidding < DeadlineEvaluation < BeginDate < EndDate * AdmissionPrice>0 * Id-unique */ public int addConference(Model.Conference c) { if (c.AdmissionPrice < 1) { throw new Exception("Conference admission price must be >=1!"); } if ((DateTime.Compare(c.DeadlineAbstract, c.DeadlineComplet) < 0) && (DateTime.Compare(c.DeadlineComplet, c.DeadlineParticipation) < 0) && (DateTime.Compare(c.DeadlineParticipation, c.DeadlineBidding) < 0)) { if ((DateTime.Compare(c.DeadlineBidding, c.DeadlineEvaluation) < 0) && (DateTime.Compare(c.DeadlineEvaluation, c.BeginDate) < 0) && (DateTime.Compare(c.BeginDate, c.EndDate) < 0)) { foreach (Model.Conference conf in getConferences()) { if (conf.Id == c.Id) { throw new Exception("Conference already exist!"); } } Conference conference = new Conference(); conference.ConferenceId = c.Id; conference.Name = c.Name; conference.Edition = c.Edition; conference.DeadlineAbstractPaper = c.DeadlineAbstract; conference.DeadlineBiddingPaper = c.DeadlineBidding; conference.DeadlineCompletePaper = c.DeadlineComplet; conference.DeadlineEvaluation = c.DeadlineEvaluation; conference.DeadlineParticipation = c.DeadlineParticipation; conference.EndDate = c.EndDate; conference.BeginDate = c.BeginDate; conference.City = c.City; conference.Country = c.Country; conference.Website = c.Website; conference.Price = c.AdmissionPrice; if (Find(conference.ConferenceId) == false) { _context.Conferences.Add(conference); _context.SaveChanges(); foreach (string topic in c.Topics) { addTopic(topic, conference.ConferenceId); } return(conference.ConferenceId); } else { throw new Exception("Conference already exists!"); } //TO DO->ADD PC MEMBERS.Astept functia } else { throw new Exception("Dates must be in chronological order!"); } } else { throw new Exception("Dates must be in chronological order!"); } }
public void UpdateConference(Model.Conference c) { //updateaza o conferinta existenta, apelat la sesiuni noi throw new NotImplementedException(); }
public void NewParticipant(Model.Conference c, Participant p) { //adauga participant nou, eventual notifica throw new NotImplementedException(); }
public void NewPaper(Model.Conference c, Model.Paper p) { Console.WriteLine("futai"); }
public void AddConference(Model.Conference conference) { repoConference.addConference(conference); }
public void UpdateConference(Model.Conference c) { repoConference.updateConference(c); }
/*Adauga un payment*/ public void NewPayment(Model.Participant p, int nrTickets, Model.Conference conf) { repoPayment.addPayment(p, nrTickets, conf); }