public static void CancelRequest(User user, int requestID) { Events evnt = EventController.GetEvent(GetRequest(requestID).EventID); if (!user.isAuthorized(evnt, EnumFunctions.Manage_Requests)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Cancel Request!")); DAL dalDataContext = new DAL(); Request request = (from requests in dalDataContext.requests where requests.RequestID == requestID select requests).FirstOrDefault(); if (request == null) { throw new FaultException<SException>(new SException(), new FaultReason("Invalid Request")); } else { Events e = EventController.GetEvent(request.EventID); if (e.Organizerid != user.UserID) // Manage Requests, View Requests User.isAuthorized( throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Edit This Request!")); request.Status = RequestStatus.Cancelled; dalDataContext.SubmitChanges(); RequestLogController.InsertRequestLog(request); } }
public static void DeleteParticipant(User user, int ParticipantID) { try { DAL dalDataContext = new DAL(); // Participant p = GetParticipant(ParticipantID); Participant p = (from participants in dalDataContext.participants where participants.ParticipantID == ParticipantID select participants).SingleOrDefault<Participant>(); //chk if user can do this anot if (!user.isAuthorized(EventController.GetEvent(p.EventID), EnumFunctions.Manage_Participant)) goto Error; dalDataContext.participants.DeleteOnSubmit(p); dalDataContext.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Deleting Participant, Please Try Again!")); } return; Error: throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Delete Participant!")); }
public static void DeleteProgram(User user, int ProgramID) { //chk if user got rights or is organizer Program P = GetPrograms(ProgramID); if (!user.isAuthorized(EventController.GetEvent(P.EventID), EnumFunctions.Delete_Programmes)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Delete Programs!")); DAL dalDataContext = new DAL(); try { Program matchedprograms = (from programs in dalDataContext.programs where programs.ProgramID == P.ProgramID select programs).FirstOrDefault(); dalDataContext.programs.DeleteOnSubmit(matchedprograms); dalDataContext.SubmitChanges(); } catch (Exception ex) { throw new FaultException<SException>(new SException(ex.Message), new FaultReason("An Error occured While Adding Deleting Program, Please Try Again!")); //throw exception here } }
public static void DeleteGuest(User user, int GuestID) { //chk if user can do this anot Guest g = GetGuest(GuestID); if (!user.isAuthorized(EventController.GetEvent(g.EventID), EnumFunctions.Delete_Guest)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Delete Guest!")); DAL dalDataContext = new DAL(); try { Guest matchedguest = (from guests in dalDataContext.guests where guests.GuestId == g.GuestId select guests).FirstOrDefault(); dalDataContext.guests.DeleteOnSubmit(matchedguest); dalDataContext.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Deleting Guest, Please Try Again!")); } }
public static int AddRightsTemplate(User user, Events evnt, string RoleTemplatePost, string RoleTemplateDescription, List<EnumFunctions> functionID) { if (!user.isSystemAdmin) { if (!user.isAuthorized(evnt, EnumFunctions.Add_Role)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Add New Role Template!")); } try { using (TransactionScope t = new TransactionScope(TransactionScopeOption.Required)) { DAL dalDataContext = new DAL(); RoleTemplate role = RoleTemplateController.AddRoleTemplate(evnt, RoleTemplatePost, RoleTemplateDescription, dalDataContext); int roleid = role.RoleTemplateID; role = null; RightTemplateController.AddRight(roleid, functionID, dalDataContext); t.Complete(); return roleid; } } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Role Template, Please Try Again!")); } }
public static string GetLastNotification(User user, string rid) { if (String.Compare(user.UserID, rid, true) != 0) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, You cannot read messages not in your inbox")); DAL dalDataContext = new DAL(); Notifications msg = (from notifs in dalDataContext.notifications where notifs.Receiver == user.UserID orderby notifs.SendDateTime descending select notifs).FirstOrDefault<Notifications>(); if (msg != null) { TimeSpan t = DateTime.Now - msg.SendDateTime; if (t > TimeSpan.FromTicks(0) && t <= TimeSpan.FromSeconds(15)) { return msg.Sender; } else { return ""; } } else return ""; }
public frmViewUsers(User u, frmMain mainFrame) : this() { this.user = u; this.mainFrame = mainFrame; this.cboRole.ItemsSource = System.Enum.GetValues(typeof(EnumRoles)); }
public static void DeleteEvent(User user, int EventID) { //chk if user can do this anot Events evnt = GetEvent(EventID); if (!user.isAuthorized(evnt)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Delete this Events!")); DAL dalDataContext = new DAL(); try { Events matchedevent = (from events in dalDataContext.events where events.EventID == evnt.EventID //events.Organizerid == user.userID select events).FirstOrDefault(); dalDataContext.events.DeleteOnSubmit(matchedevent); dalDataContext.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Deleting Event, Please Try Again!")); } }
public static void deleteItem(User user, Items iten) { if (!user.isAuthorized( EventController.GetEvent(iten.EventID), EnumFunctions.Manage_Items)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Delete Item!")); DAL dalDataContext = new DAL(); try { Items matchedItem = (from item in dalDataContext.items where item.typeString == iten.typeString && item.EventID == iten.EventID && item.ItemName == iten.ItemName select item).FirstOrDefault<Items>(); dalDataContext.items.DeleteOnSubmit(matchedItem); dalDataContext.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Deleting Item , Please Try Again!")); } }
public static void AddPointOfContact(User user, int EventID, int serviceID, string name, string position, string phone, string email) { bool allow = false; if (user.isSystemAdmin || user.isEventOrganizer) { allow = true; } if (!allow) { if (!user.isAuthorized(EventController.GetEvent(EventID), EnumFunctions.Manage_Items)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Edit this Service!")); } try { DAL dalDataContext = new DAL(); Table<PointOfContact> pointOfContact = dalDataContext.pointOfContacts; PointOfContact creatingPointOfContact = new PointOfContact(serviceID, name, position, phone, email); pointOfContact.InsertOnSubmit(creatingPointOfContact); pointOfContact.Context.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Point of Contact, Please Try Again!")); } }
public static void AddService(User user, int EventID, string Address, string name, string url, string notes) { bool allow = false; if (user.isSystemAdmin || user.isEventOrganizer) { allow = true; } if (!allow) { if (!user.isAuthorized(EventController.GetEvent(EventID), EnumFunctions.Manage_Items)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Edit this Service!")); } try { DAL dalDataContext = new DAL(); Table<Service> services = dalDataContext.services; Service creatingService = new Service(Address, name, url, notes); services.InsertOnSubmit(creatingService); services.Context.SubmitChanges(); dalDataContext.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Service, Please Try Again!")); } }
public static void SetBought(User user, Items iten) { //if (!user.isAuthorized(user, EventController.GetEvent(iten.EventID), EnumFunctions.Manage_Items)) // throw new FaultException<SException>(new SException(), // new FaultReason("Invalid User, User Does Not Have Rights To Update Items properties!")); try { DAL dalDataContext = new DAL(); OptimizedBudgetItemsDetails matchedItem = (from item in dalDataContext.optimizedBudgetItemDetails where item.typeString == iten.typeString && item.EventID == iten.EventID && item.ItemName == iten.ItemName select item).FirstOrDefault<OptimizedBudgetItemsDetails>(); if (matchedItem == null) { throw new FaultException<SException>(new SException(), new FaultReason("Invalid Item ")); } else { matchedItem.IsBought = true; dalDataContext.SubmitChanges(); } } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Updating Item, Please Try Again!")); } }
public static int AddRoleAndRights(User user, string RoleUserID, int EventID, string RolePost, string RoleDescription, List<EnumFunctions> functionID) { if (!user.isAuthorized(EventController.GetEvent(EventID), EnumFunctions.Add_Role)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Add New Role!")); try { using (TransactionScope t = new TransactionScope(TransactionScopeOption.Required)) { DAL dalDataContext = new DAL(); Role role = RoleController.AddRole(RoleUserID, EventID, RolePost, RoleDescription, dalDataContext); int roleid = role.RoleID; role = null; RightController.AddRight(roleid, functionID, dalDataContext); NotificationController.sendNotification(user.UserID, RoleUserID, "Rights changed", "Your Rights Have been changed for the Event " + EventController.GetEvent(EventID).Name); t.Complete(); return roleid; } } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Role, Please Try Again!")); } }
public User(User user) { this.name = user.name; this.email = user.email; this.u_password = user.u_password; this.uid = user.UserID; }
public static void DeleteFolder(User user, int eventID, string folderName) { Events evnt = EventController.GetEvent(eventID); //TODO: Add Enum CreateArtefactFolder in functions - Nick if (!RoleLogicController.HaveRights(evnt, user, EnumFunctions.Manage_Artefacts)) //user.isAuthorized(evnt, ManageArtefact) after enum f(x) up throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User does not have rights to Delete Folder!")); DAL dalDataContext = new DAL(); try { WorkspaceFolders matchedWS = (from ws in dalDataContext.ArtefactWSFolders where ws.EventID == eventID && ws.FolderName.ToLower() == folderName.ToLower() select ws).FirstOrDefault(); if (matchedWS != null) { dalDataContext.ArtefactWSFolders.DeleteOnSubmit(matchedWS); dalDataContext.SubmitChanges(); } } catch (Exception ex) { throw new FaultException<SException>(new SException(ex.Message), new FaultReason("An Error occured While Deleting Workspace, Please Try Again!")); } }
public static void AddRight(User user, int roleID, List<EnumFunctions> functionID) { //chk if user can do this anot try { DAL dalDataContext = new DAL(); Table<Right> rights = dalDataContext.rights; //using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required)) //{ for (int i = 0; i < functionID.Count; i++) { rights.InsertOnSubmit(new Right(roleID, functionID[i])); } rights.Context.SubmitChanges(); //use this to Create rights //if error need to delete it // throw new Exception(); //tScope.Complete(); // } } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Right, Please Try Again!")); } }
public static void DeleteReview(User user, string UserID, int ServiceID) { Review r = GetReview(UserID, ServiceID); if (!user.isSystemAdmin && !(user.UserID == UserID)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Delete Review!")); //chk if user can do this anot DAL dalDataContext = new DAL(); try { r = (from review in dalDataContext.reviews where review.UserID == UserID && review.ServiceID == ServiceID select review).FirstOrDefault(); dalDataContext.reviews.DeleteOnSubmit(r); dalDataContext.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Deleting Review, Please Try Again!")); } }
//Delete the task public static void DeleteTask(User user, int TaskID, int eventID) { Task taskToDelete = GetTask(TaskID); //TODO: Put in after roles management for task up if (!user.isAuthorized(EventController.GetEvent(taskToDelete.EventID), EnumFunctions.Delete_Task)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Delete Tasks!")); DAL dalDataContext = new DAL(); try { Task matchedTask = (from tasks in dalDataContext.tasks where tasks.TaskID == taskToDelete.TaskID && tasks.EventID == taskToDelete.EventID select tasks).FirstOrDefault(); dalDataContext.tasks.DeleteOnSubmit(matchedTask); dalDataContext.SubmitChanges(); } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Deleting Guest, Please Try Again!")); } }
public static List<FieldAnswer> GetParticipantFieldAnswer(User user, int EventID, int ParticipantID) { if (!user.isAuthorized(EventController.GetEvent(EventID), EnumFunctions.Manage_Participant)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Manage Participant!")); return FieldAnswerController.ViewFieldAnswer(ParticipantID); }
public static void DeleteRole(User user, int RoleID) { if (!user.isAuthorized(EventController.GetEvent(RoleController.GetRole(RoleID).EventID), EnumFunctions.Add_Role)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Add Delete This Role!")); RoleController.DeleteRole(user, RoleID); }
public frmBudgetItemList(User u, Events e) : this() { this.user = u; this.event_ = e; this.lvBItem.lv.SelectionChanged += lv_SelectionChanged; loadBudgetItems(); }
public frmFacBookingDetails(User u, Events e, EventDay d,List<Facility> m) : this() { this.user = u; this.models = m; this.event_ = e; this.eventDay_ = d; }
public static void AssignTasks(User user, int eventID, int roleID, List<Task> taskList) { //TODO: Put in after roles management for task up if (!user.isAuthorized(EventController.GetEvent(eventID), EnumFunctions.Assign_Task) || !user.isAuthorized(EventController.GetEvent(eventID), EnumFunctions.Add_Task)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Assign Tasks!")); if (taskList.Count == 0) { RemoveAllTasksFromRole(eventID, roleID); string msg = "Your task(s) assigned by " + user.Name + " for the Event: " + EventController.GetEvent(eventID).Name + " has been removed"; NotificationController.sendNotification(user.UserID, RoleController.GetRole(roleID).UserID, "Task(s) Allocated Removed", msg); return; } else { DAL dalDataContext = new DAL(); using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required)) { try { List<TaskAssignment> taskAssignmentList = new List<TaskAssignment>(); RemoveAllTasksFromRole(eventID, roleID); foreach (Task t in taskList) { if (!IsAssignmentCompleted(t.EventID, roleID, t.TaskID)){ TaskAssignment tAssn = new TaskAssignment(t.EventID, t.TaskID, roleID); taskAssignmentList.Add(tAssn); } } RemoveAllTasksFromRole(eventID, roleID); Table<TaskAssignment> taskAssns = dalDataContext.taskAssignments; taskAssns.InsertAllOnSubmit(taskAssignmentList); taskAssns.Context.SubmitChanges(); string msg = "You were allocated some tasks by " + user.Name + " for the Event: " + EventController.GetEvent(eventID).Name; NotificationController.sendNotification(user.UserID, RoleController.GetRole(roleID).UserID, "New Task Allocated", msg); tScope.Complete(); } catch (Exception ex) { throw new FaultException<SException>(new SException(ex.Message), new FaultReason("An Error occured While Adding Assigning Tasks: " + ex.Message)); } } } }
public frmAllocateBudget(User u, Events e, List<ItemTypes> typeList, List<Items> itemList, decimal maxBudget) : this() { this.user = u; this.event_ = e; this.typeList = typeList; this.itemList = itemList; this.maxBudget = maxBudget; }
public void EditItemType(User u, Events event_, Boolean Important) { EventItemsHelper client = new EventItemsHelper(); //Insert server code here ItemTypes Item2Edit=ItemTypeCollection[lv.SelectedIndex]; ItemTypeCollection[lv.SelectedIndex].IsImportantType = Important; client.SetItemTypeImportance(u, Item2Edit, Important); client.Close(); }
public frmServiceContactList(User u, Events e) : this() { txtsearch.TextChanged += txtsearch_TextChanged; this.user = u; if (e != null) { this.event_ = e; } // Insert code required on object creation below this point. }
public static void AddEvent(User user, string EventName, DateTime EventStartDateTime, DateTime EventEndDatetime, string EventDescription, string EventWebsite, string EventTag) { if (!user.isEventOrganizer) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Create Events!")); if (EventStartDateTime.CompareTo(EventEndDatetime) >= 0) { throw new FaultException<SException>(new SException(), new FaultReason("Invalid Date Entry, End Date Must be at a Later Date Then Start Date")); } if (EventName.Trim() == "") { throw new FaultException<SException>(new SException(), new FaultReason("Invalid Event Name")); } try { DAL dalDataContext = new DAL(); using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required)) { Events e = EventController.AddEvent(user, EventName, EventStartDateTime, EventEndDatetime, EventDescription, EventWebsite, EventTag, dalDataContext); DateTime current_date = EventStartDateTime.Date; current_date = current_date.AddHours(EventStartDateTime.Hour); current_date = current_date.AddMinutes(EventStartDateTime.Minute); DateTime end_date = EventEndDatetime.Date; end_date = end_date.AddHours(EventEndDatetime.Hour); end_date = end_date.AddMinutes(EventEndDatetime.Minute); int day = 1; do { DayController.AddDay(e.EventID, day, dalDataContext); day++; current_date = current_date.Date; current_date = current_date.AddDays(1); } while (current_date < end_date); tScope.Complete(); } } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Event, Please Try Again!")); } }
//not prefered as assumed user can make object.. unless use from previously returned public static void DeleteRoleTemplate(User user, int RoleTemplateID) { //for now i use Add role enum may need to make template for Add_Role_Template if (!user.isSystemAdmin) { if (!user.isAuthorized(EventController.GetEvent(RoleTemplateController.GetRoleTemplate(RoleTemplateID).EventID.Value), EnumFunctions.Add_Role)) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Delete This Role Template!")); } RoleTemplateController.DeleteRoleTemplate(user, RoleTemplateID); }
public static EventWithDays AddEvent(User user, string EventName, DateTime EventStartDateTime, DateTime EventEndDatetime, string EventDescription, string EventWebsite, string EventTag, DAL dalDataContext) { if (!user.isEventOrganizer) throw new FaultException<SException>(new SException(), new FaultReason("Invalid User, User Does Not Have Rights To Create Events!")); if (EventStartDateTime.CompareTo(EventEndDatetime) >= 0) { throw new FaultException<SException>(new SException(), new FaultReason("Invalid Date Entry, End Date Must be at a Later Date Then Start Date")); } if (EventName.Trim() == "") { throw new FaultException<SException>(new SException(), new FaultReason("Invalid Event Name")); } try { Events e = EventController.AddEvent(user, EventName, EventStartDateTime, EventEndDatetime, EventDescription, EventWebsite, EventTag, dalDataContext); DateTime current_date = EventStartDateTime.Date; current_date = current_date.AddHours(EventStartDateTime.Hour); current_date = current_date.AddMinutes(EventStartDateTime.Minute); DateTime end_date = EventEndDatetime.Date; end_date = end_date.AddHours(EventEndDatetime.Hour); end_date = end_date.AddMinutes(EventEndDatetime.Minute); int day = 1; EventWithDays ed = new EventWithDays(); ed.e = e; do { EventDay d = DayController.AddDay(e.EventID, day, dalDataContext); day++; ed.ds.Add(d); current_date = current_date.Date; current_date = current_date.AddDays(1); } while (current_date < end_date); return ed; } catch { throw new FaultException<SException>(new SException(), new FaultReason("An Error occured While Adding New Event, Please Try Again!")); } }
public void DeleteItemType(User u, Events event_) { EventItemsHelper client = new EventItemsHelper(); //Insert server code here if (lv.SelectedIndex != -1) { ItemTypes type2delete = ItemTypeCollection[lv.SelectedIndex]; client.DeleteEventItemType(u, type2delete); ItemTypeCollection.RemoveAt(lv.SelectedIndex); } client.Close(); }