Ejemplo n.º 1
0
        //if existing then return the existing otp
        public static void InsertRequestLog(Request r)
        {
            try
            {
                DAL dalDataContext = new DAL();
                Table<RequestLog> requestLogs = dalDataContext.requestLogs;

                RequestLog newRequestLog = new RequestLog(r.RequestID, r.Description, r.Remark, r.Status, r.URL);
                dalDataContext.requestLogs.InsertOnSubmit(newRequestLog);
                dalDataContext.SubmitChanges();

            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(ex.Message),
                  new FaultReason("An Error occured While Creating New Requestee: " + ex.Message));
            }
        }
Ejemplo n.º 2
0
        //pending ->approve , disapprove
        //approve ->nth
        //disapprove ->pending,approve
        public static string CreateNewRequest(User user, int eventid, string targetEmail, string description, string uRL, string title)
        {
            Events evnt = EventController.GetEvent(eventid);
            if (!user.isAuthorized(evnt, EnumFunctions.Manage_Requests))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Create Request!"));
            using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
            {

                DAL dalDataContext = new DAL();
                try
                {

                    Table<Request> requests = dalDataContext.requests;

                    Events e = EventController.GetEvent(eventid);

                    if (!e.Organizerid.Equals(user.UserID, StringComparison.CurrentCultureIgnoreCase))
                        throw new FaultException<SException>(new SException(),
                      new FaultReason("Error, User is not Organizer of this event"));

                    string otp = RequesteeController.CreateNewRequestee(targetEmail, dalDataContext);
                    Request newrequest = new Request(eventid, targetEmail, description, uRL, DateTime.Now, user.UserID, title);

                    requests.InsertOnSubmit(newrequest);
                    requests.Context.SubmitChanges();

                    RequestLogController.InsertRequestLog(newrequest);
                    tScope.Complete();

                    return otp;
                }
                catch (Exception ex)
                {
                    throw new FaultException<SException>(new SException(ex.Message),
                      new FaultReason("An Error occured While Creating New Request: " + ex.Message));
                }
            }
        }