Exemplo n.º 1
0
        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));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void AddSingleAssignment(User user, int eventID, int roleID, Task task)
        {
            //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!"));

            DAL dalDataContext = new DAL();
            TaskAssignment taskAssn = new TaskAssignment(eventID, task.TaskID, roleID);
            Table<TaskAssignment> assignmentTable = dalDataContext.taskAssignments;

            assignmentTable.InsertOnSubmit(taskAssn);
            assignmentTable.Context.SubmitChanges();
        }
Exemplo n.º 3
0
        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!"));
            }
        }
Exemplo n.º 4
0
        //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!"));
            }
        }
Exemplo n.º 5
0
        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!"));
            }
        }
Exemplo n.º 6
0
        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!"));
        }
Exemplo n.º 7
0
        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
            }
        }
Exemplo n.º 8
0
        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 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!"));
            }
        }
Exemplo n.º 10
0
        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!"));
            }
        }
Exemplo n.º 11
0
        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!"));
            }
        }
Exemplo n.º 12
0
        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!"));
            }
        }
Exemplo n.º 13
0
        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!"));
            }
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }
        //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);
        }
Exemplo n.º 17
0
        public static void Review(User user, int EventID, int serviceID, int rating, DateTime reviewDate, string reviewDescription)
        {
            bool allow = false;

            if ((user.isEventOrganizer) || (user.isSystemAdmin))
                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 Add New Review!"));
            }
            try
            {
                DAL dalDataContext = new DAL();
                Table<Review> reviews = dalDataContext.reviews;

                Review existingReview = (from review in dalDataContext.reviews
                                         where review.UserID == user.UserID &&
                                         review.ServiceID == serviceID
                                         select review).FirstOrDefault();

                if (existingReview == null)
                {
                    Review creatingReview = new Review(serviceID, user.UserID, user.Name, rating,
                        reviewDate, reviewDescription);

                    reviews.InsertOnSubmit(creatingReview);
                }
                else
                {
                    existingReview.UserID = user.UserID;
                    existingReview.UserName = user.Name;
                    existingReview.ServiceID = serviceID;
                    existingReview.Rating = rating;
                    existingReview.ReviewDate = reviewDate;
                    existingReview.ReviewDescription = reviewDescription;
                }
                reviews.Context.SubmitChanges();

                dalDataContext.SubmitChanges();
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Review, Please Try Again!"));
            }
        }
Exemplo n.º 18
0
        public static void EditPointOfContact(User user, int EventID, int PointOfContactID, 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();

                PointOfContact pointOfContact = (from poc in dalDataContext.pointOfContacts
                                                 where poc.PointOfContactID == PointOfContactID
                                                 select poc).FirstOrDefault();
                if (pointOfContact == null)
                {

                    throw new FaultException<SException>(new SException(),
                       new FaultReason("Invalid Point Of Point Of Contact"));
                }
                else
                {
                    pointOfContact.Name = name;
                    pointOfContact.Position = position;
                    pointOfContact.Phone = phone;
                    pointOfContact.Email = email;
                    dalDataContext.SubmitChanges();

                }
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Editing Point Of Contact, Please Try Again!"));
            }
        }
Exemplo n.º 19
0
        public static void EditBudgetIncome(User user, int EventID, int IncomeID, BudgetIncome bIncome)
        {
            if (!user.isAuthorized(EventController.GetEvent(EventID), EnumFunctions.Manage_Income))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Edit Income!"));

            if (IncomeID == -1)
                throw new FaultException<SException>(new SException(),
                    new FaultReason("Cannot edit partipants payment data!"));

            try
            {
                DAL dalDataContext = new DAL();

                BudgetIncome matchedincome = (from income in dalDataContext.income
                                              where income.IncomeID == IncomeID &&
                                              income.EventID == EventID
                                              select income).FirstOrDefault();

                if (matchedincome == null)
                {
                    throw new FaultException<SException>(new SException(),
                       new FaultReason("Invalid Income Item"));
                }
                else
                {
                    matchedincome.Name = bIncome.Name;
                    matchedincome.Description = bIncome.Description;
                    matchedincome.IsGstLiable = bIncome.IsGstLiable;
                    matchedincome.IncomeBeforeGST = bIncome.IncomeBeforeGST;
                    matchedincome.GstValue = bIncome.GstValue;
                    matchedincome.Source = bIncome.Source;
                    matchedincome.DateReceived = bIncome.DateReceived;
                    dalDataContext.SubmitChanges();

                }
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Editing Income, Please Try Again!"));
            }
        }
Exemplo n.º 20
0
        public static int AddBudgetIncome(User user, int EventID, BudgetIncome bIncome)
        {
            if (!user.isAuthorized(EventController.GetEvent(EventID), EnumFunctions.Manage_Income))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Add Income!"));
            try
            {
                DAL dalDataContext = new DAL();
                Table<BudgetIncome> income = dalDataContext.income;

                income.InsertOnSubmit(bIncome);
                income.Context.SubmitChanges();

                return bIncome.IncomeID;
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Income, Please Try Again!"));
            }
        }
Exemplo n.º 21
0
        //Create a new task without assigning to anyone
        public static void CreateTask(User user, int eventID, string taskName,
            string taskDesc, DateTime DueDate)
        {
            //TODO: Put in after roles management for task up
            if (!user.isAuthorized(EventController.GetEvent(eventID), EnumFunctions.Add_Task))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Add Tasks!"));
            try
            {
                DAL dalDataContext = new DAL();
                Table<Task> taskTable = dalDataContext.tasks;
                Task task = new Task(eventID, taskName, taskDesc, DueDate);

                taskTable.InsertOnSubmit(task);
                taskTable.Context.SubmitChanges();
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Task, Please Try Again!"));
            }
        }
Exemplo n.º 22
0
        public static int AddGuest(User user, int dayID, string GuestName, string GuestContact, string GuestDescription)
        {
            if (!user.isAuthorized(EventController.GetEvent(DayController.GetDay(dayID).EventID), EnumFunctions.Add_Guest))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Add Guests!"));
            try
            {
                DAL dalDataContext = new DAL();
                Table<Guest> guests = dalDataContext.guests;
                Guest creatingguest = new Guest(GuestName, GuestContact, GuestDescription, dayID);

                guests.InsertOnSubmit(creatingguest);
                guests.Context.SubmitChanges();

                return creatingguest.GuestId;
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Guest, Please Try Again!"));
            }
        }
Exemplo n.º 23
0
        public static Items AddItem(User user, ItemTypes type, string name, int sat, decimal est)
        {
            if (!user.isAuthorized( EventController.GetEvent(type.EventID), EnumFunctions.Manage_Items))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Add Items!"));

            if (GetItem(type, name) == null)
            {
                DAL dalDataContext = new DAL();
                Table<Items> itemTable = dalDataContext.items;
                Items newItem = new Items(type, name, sat, est);

                itemTable.InsertOnSubmit(newItem);
                itemTable.Context.SubmitChanges();

                return newItem;
            }
            else
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Item already exist!"));
            }
        }
Exemplo n.º 24
0
        public static int AddProgram(User user, string ProgramName, DateTime ProgramStartDateTime, DateTime ProgramEndDatetime,
            string ProgramDescription, int ProgramDayID, string ProgramLocation)
        {
            if (!user.isAuthorized(EventController.GetEvent(DayController.GetDay(ProgramDayID).EventID), EnumFunctions.Create_Programmes))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Add Programs!"));

            try
            {
                DAL dalDataContext = new DAL();
                Table<Program> programs = dalDataContext.programs;
                Program newProgram = new Program(ProgramName, ProgramStartDateTime, ProgramEndDatetime, ProgramDescription, ProgramDayID, ProgramLocation);
                programs.InsertOnSubmit(newProgram);
                programs.Context.SubmitChanges();

                return newProgram.ProgramID;
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Program, Please Try Again!"));
            }
        }
Exemplo n.º 25
0
        public static ItemTypes AddItemType(User user, int evid, string type, bool isImpt)
        {
            if (!user.isAuthorized( EventController.GetEvent(evid), EnumFunctions.Manage_ItemTypes))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Add Items!"));

                ItemTypes iType = GetItemType(evid, type);
                if (iType == null)
                {
                    DAL dalDataContext = new DAL();
                    Table<ItemTypes> typeTable = dalDataContext.itemTypes;
                    ItemTypes newItemType = new ItemTypes(evid, type, isImpt);

                    typeTable.InsertOnSubmit(newItemType);
                    typeTable.Context.SubmitChanges();
                    return newItemType;
                }
                else
                {
                    throw new FaultException<SException>(new SException(),
                   new FaultReason("Item type already exist!"));
                }
        }
Exemplo n.º 26
0
        public static void deleteItemType(User user, ItemTypes type)
        {
            if (!user.isAuthorized( EventController.GetEvent(type.EventID), EnumFunctions.Manage_ItemTypes))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Delete Guest!"));

            DAL dalDataContext = new DAL();

            try
            {
                ItemTypes itemType = (from iType in dalDataContext.itemTypes
                                      where iType.EventID == type.EventID
                                      && iType.typeString == type.typeString
                                      select iType).FirstOrDefault<ItemTypes>();

                dalDataContext.itemTypes.DeleteOnSubmit(itemType);
                dalDataContext.SubmitChanges();
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Deleting Item Type, Please Try Again!"));
            }
        }
Exemplo n.º 27
0
        public static void DeleteBudgetIncome(User user, int BudgetIncomeID, int eventID)
        {
            if (!user.isAuthorized(EventController.GetEvent(eventID), EnumFunctions.Manage_Income))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Delete Income!"));

            DAL dalDataContext = new DAL();

            try
            {
                BudgetIncome matchedincome = (from income in dalDataContext.income
                                              where income.IncomeID == BudgetIncomeID &&
                                               income.EventID == eventID
                                              select income).FirstOrDefault();

                dalDataContext.income.DeleteOnSubmit(matchedincome);
                dalDataContext.SubmitChanges();
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Deleting Income, Please Try Again!"));
            }
        }
Exemplo n.º 28
0
        public static void setItemTypeImportance(User user, ItemTypes type, bool isImpt)
        {
            if (!user.isAuthorized( EventController.GetEvent(type.EventID), EnumFunctions.Manage_ItemTypes))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Edit this Guest!"));
            try
            {
                DAL dalDataContext = new DAL();

                ItemTypes matchedItem = (from iten in dalDataContext.itemTypes
                                         where iten.EventID == type.EventID
                                         && iten.typeString == type.typeString
                                         select iten).FirstOrDefault<ItemTypes>();

                if (matchedItem == null)
                {
                    throw new FaultException<SException>(new SException(),
                       new FaultReason("Invalid Item Type"));
                }
                else
                {
                    matchedItem.IsImportantType = isImpt;
                    dalDataContext.SubmitChanges();

                }
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Updating Item Type, Please Try Again!"));
            }
        }
Exemplo n.º 29
0
        public static List<BudgetIncome> ViewBudgetIncome(User user, int eventID)
        {
            if (!user.isAuthorized(EventController.GetEvent(eventID), EnumFunctions.Manage_Income))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To View income!"));
            try
            {
                DAL dalDataContext = new DAL();

                List<BudgetIncome> BudgetIncomes = (from income in dalDataContext.income
                                                    where income.EventID == eventID
                                                    select income).ToList<BudgetIncome>();

                //Todo, add a new budgetIncome item to the list for participant payments
                decimal participantsIncome = ParticipantController.GetEventParticipantIncome(eventID);

                if (participantsIncome > 0)
                {
                    BudgetIncome partiIncome = new BudgetIncome(eventID, "Participants Registration Fees",
                                                                "Income that came from participants Income",
                                                                false, participantsIncome, 0, "Participants Registration",
                                                                DateTime.Now, -1);

                    BudgetIncomes.Add(partiIncome);
                }

                return BudgetIncomes;
            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(ex.Message),
                   new FaultReason("An Error occured Retrieving Income data, Please Try Again!"));
            }
        }
Exemplo n.º 30
0
        //Set task to not completed however need rights not anyone can do this
        //to prevent sabo
        public static void SetInComplete(User authorizedPerson, Task completedTask, int roleID, string remarks)
        {
            if (!authorizedPerson.isAuthorized(EventController.GetEvent(completedTask.EventID), EnumFunctions.Update_Task))
                throw new FaultException<SException>(new SException(),
                   new FaultReason("Invalid User, User Does Not Have Rights To Update Tasks!"));
            DAL dalDataContext = new DAL();
            try
            {
                TaskAssignment taskAssigned = (from tAssn in dalDataContext.taskAssignments
                                               where tAssn.TaskID == completedTask.TaskID &&
                                               tAssn.EventID == completedTask.EventID &&
                                               tAssn.AssignedRoleID == roleID
                                               select tAssn).SingleOrDefault();

                taskAssigned.IsCompleted = false;
                taskAssigned.Remarks = remarks;
                dalDataContext.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(),
                  new FaultReason(ex.Message));
            }
        }