コード例 #1
0
        public void RenewRequest(Request request, Person person, DateTime startDate, DateTime endDate)
        {
            using (var context = new ProgDatabaseEntities())
            {
                Decision _newDecision = new Decision();
                Action   _renewAction = new Action();
                _renewAction = context.Actions.Where(a => a.DisplayName == "Renew").Single();

                _newDecision.Action1 = _renewAction;

                _newDecision.Request    = context.Requests.Where(r => r.RequestID == request.RequestID).Single();
                _newDecision.Person1    = context.People.Where(p => p.PersonID == person.PersonID).Single();
                _newDecision.ChangeDate = DateTime.Now;
                _newDecision.Reason     = "Renew initiated by " + person.ToString();

                context.Decisions.Add(_newDecision);

                DecisionLevel _newDecisionLevel = new DecisionLevel();
                _newDecisionLevel = context.DecisionLevels.Where(d => d.DecisionLevel1 == 1).Single();

                Request _request = new Request();
                _request = context.Requests.Where(r => r.RequestID == request.RequestID).Single();
                _request.DecisionLevel = _newDecisionLevel;
                _request.ValidityStart = startDate;
                _request.ValidityEnd   = endDate;

                context.SaveChanges();
            }
        }
コード例 #2
0
        public void DenyRequest(Request request, Action action, Person approver, string reason)
        {
            using (var context = new ProgDatabaseEntities())
            {
                Decision _newDecision = new Decision();
                _newDecision.Action1    = context.Actions.Where(a => a.ActionID == action.ActionID).Single();
                _newDecision.Request    = context.Requests.Where(r => r.RequestID == request.RequestID).Single();
                _newDecision.Person1    = context.People.Where(p => p.PersonID == approver.PersonID).Single();
                _newDecision.ChangeDate = DateTime.Now;
                _newDecision.Reason     = reason;
                context.Decisions.Add(_newDecision);

                DecisionLevel _newDecisionLevel = new DecisionLevel();
                _newDecisionLevel = context.DecisionLevels.Where(d => d.DecisionLevel1 == 4).Single();

                Request _request = new Request();
                _request = context.Requests.Where(r => r.RequestID == request.RequestID).Single();
                _request.DecisionLevel = _newDecisionLevel;

                context.SaveChanges();
            }
        }