Beispiel #1
0
        public void Add(Message m)
        {
            MessagesC mess = new MessagesC();

            mess.MessageBody = m.MessageBody;
            mess.MessageId   = m.MessageId;
            mess.UserId      = m.UserId;

            _context.MessagesCs.Add(mess);
            _context.SaveChanges();
        }
Beispiel #2
0
        public void Add(Model.User u)
        {
            User newser = new User();

            newser.Username      = u.Username;
            newser.Name          = u.Name;
            newser.Password      = u.Password;
            newser.Email         = u.Email;
            newser.Affilliation  = u.Affiliation;
            newser.WebPage       = u.Website;
            newser.canBePCMember = u.isSpecial;

            _context.Users.Add(newser);
            _context.SaveChanges();
        }
Beispiel #3
0
        /*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();
                }
            }
        }
Beispiel #4
0
        public void Add(Model.Paper p)
        {
            Paper paper = new Paper();

            paper.Name             = p.Title;
            paper.Resume           = p.Resume;
            paper.Domain           = p.Domain;
            paper.Subdomain        = p.Subdomain;
            paper.Filepath         = p.Filepath;
            paper.EvaluationResult = Enum.GetName(p.Status.GetType(), p.Status);
            paper.IsEmailSent      = false;
            paper.ConferenceId     = p.ConferenceId;
            paper.UserId           = p.Uploader.IdUser;
            //paper.TopicId get topic by name and conf
            foreach (Topic topic in _context.Topics)
            {
                if (topic.TopicName == p.Topic && topic.ConferenceId == p.ConferenceId)
                {
                    paper.TopicId = topic.TopicId;
                    break;
                }
            }

            _context.Papers.Add(paper);
            _context.SaveChanges();

            foreach (Author author in p.AdditionalAuthors)
            {
                if (_context.AdditionalAuthors.Find(author.IdAuthor) == null)
                {
                    AdditionalAuthor aa = new AdditionalAuthor();
                    aa.Affiliation = author.Affiliation;
                    aa.Name        = author.Name;
                    aa.PaperId     = paper.PaperId;
                    _context.AdditionalAuthors.Add(aa);
                }
            }

            _context.SaveChanges();
        }
Beispiel #5
0
        public void Add(Participant p)
        {
            if (p.IsNormalUser == true)
            {
                ConferenceParticipant participant = new ConferenceParticipant();
                participant.UserId       = p.User.IdUser;
                participant.ConferenceId = p.ConferenceId;
                participant.PaymentId    = 1;

                _context.ConferenceParticipants.Add(participant);
                _context.SaveChanges();
            }
            else
            {
                PCMember pcm = new PCMember();
                pcm.UserId       = p.User.IdUser;
                pcm.ConferenceId = p.ConferenceId;
                pcm.isChair      = p.IsChair;
                pcm.isCoChair    = p.IsCochair;

                _context.PCMembers.Add(pcm);
                _context.SaveChanges();
            }
        }
Beispiel #6
0
        public void Add(int confId, string roomName, int capacity, string street, string city, string postalCode, DateTime beginDate, DateTime endDate)
        {
            AvailableRoom ar = new AvailableRoom();

            ar.ConferenceId = confId;
            ar.RoomName     = roomName;
            ar.Capacity     = capacity;
            ar.BeginDate    = beginDate;
            ar.EndDate      = endDate;

            int aId = -1;

            foreach (Address a in _context.Addresses)
            {
                if (a.City == city && a.Street == street && a.PostalCode == postalCode)
                {
                    aId = a.AddressId;
                    break;
                }
            }

            if (aId == -1)
            {
                Address a = new Address();
                a.City       = city;
                a.Street     = street;
                a.PostalCode = postalCode;
                _context.Addresses.Add(a);
                _context.SaveChanges();
                aId = a.AddressId;
            }

            ar.AddressId = aId;
            _context.AvailableRooms.Add(ar);
            _context.SaveChanges();
        }
Beispiel #7
0
        /*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!");
            }
        }