Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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!"));
            }
        }
Ejemplo n.º 3
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!"));
        }
        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!"));
            }
        }
Ejemplo n.º 5
0
        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 "";
        }
Ejemplo n.º 6
0
        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!"));
            }
        }
Ejemplo n.º 7
0
        public static void EditRole(int RoleID, string RoleUserID, string RolePost, string RoleDescription, DAL dalDataContext)
        {
            try
            {

                Role matchedrole = (from roles in dalDataContext.roles
                                    where roles.RoleID == RoleID
                                    select roles).FirstOrDefault();

                if (matchedrole == null)
                {

                    throw new FaultException<SException>(new SException(),
                       new FaultReason("Invalid Role"));
                }
                else
                {
                    matchedrole.Description = RoleDescription;
                    matchedrole.Post = RolePost;
                    matchedrole.UserID = RoleUserID;

                    dalDataContext.SubmitChanges();
                }
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Editing Role, Please Try Again!"));
            }
        }
Ejemplo n.º 8
0
        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!"));
            }
        }
Ejemplo n.º 9
0
 public static void AddFieldAnswer(int FieldID, int ParticipantID, string Answer, DAL dalDataContext)
 {
     try
     {
         //Event evnt = EventController.GetEvent(EventID);
         //if(e == null)
         //    throw new FaultException<SException>(new SException(),
         //   new FaultReason("Invalid Event ID"));
         FieldAnswer fa = GetFieldAnswer(ParticipantID, FieldID);
         //DAL dalDataContext = new DAL();
         Table<FieldAnswer> fieldAnswers = dalDataContext.fieldAnswer;
         if (fa == null)
         {
             FieldAnswer CreateFieldAns = new FieldAnswer(ParticipantID, FieldID, Answer);
             fieldAnswers.InsertOnSubmit(CreateFieldAns);
             fieldAnswers.Context.SubmitChanges();
         }
         else
         {
             fa.Answer = Answer;
             dalDataContext.SubmitChanges();
         }
     }
     catch
     {
         throw new FaultException<SException>(new SException(),
            new FaultReason("An Error occured While Adding New Field Answer, Please Try Again!"));
     }
 }
Ejemplo n.º 10
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!"));
            }
        }
Ejemplo n.º 11
0
        public static User authenticate(Credentials credentials)
        {
            User user = null;
            DAL dalDataContext = new DAL();

            try
            {
                user = (from users in dalDataContext.users
                        where users.UserID == credentials.UserID
                        select users).FirstOrDefault<User>();
                if (user == null)
                {
                    throw new FaultException<SException>(new SException(),
                  new FaultReason("Invalid User, Please try again"));
                }
                else if (user.User_Password.CompareTo(KeyGen.Decrypt(credentials.Password)) != 0)
                {
                    throw new FaultException<SException>(new SException(),
                   new FaultReason("Wrong Password!, please try again"));
                }
                else
                {
                    user.GetSystemRole();
                }
            }
            catch (InvalidOperationException ex)
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An error had occured: " + ex.Message));
            }
            return user;
        }
Ejemplo n.º 12
0
        public static RoleTemplate AddRoleTemplate(Events evnt, string RoleTemplatePost, string RoleTemplateDescription, DAL dalDataContext)
        {
            try
            {

                Table<RoleTemplate> roles = dalDataContext.roleTemplate;
                RoleTemplate creatingRole;
                //if(e == null)
                creatingRole = new RoleTemplate(RoleTemplatePost, RoleTemplateDescription, evnt);
                //else
                //    creatingRole = new RoleTemplate(RoleTemplatePost, RoleTemplateDescription, evnt.EventID);

                roles.InsertOnSubmit(creatingRole);

                roles.Context.SubmitChanges();

                return creatingRole;

            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Role Template, Please Try Again!"));
            }
        }
Ejemplo n.º 13
0
        //if existing then return the existing otp
        public static string CreateNewRequestee(string targetEmail)
        {
            DAL dalDataContext = new DAL();
            try
            {

                Table<Requestee> requestees = dalDataContext.requestees;

                Requestee existingRequestee = (from requestee in dalDataContext.requestees
                                               where requestee.TargetEmail.ToLower() == targetEmail.ToLower()
                                                select requestee).SingleOrDefault<Requestee>();

                if (existingRequestee == null)
                {
                    string otp = OTPGenerator.Generate();

                    Requestee newRequestee = new Requestee(targetEmail,otp);
                    dalDataContext.requestees.DeleteOnSubmit(newRequestee);
                    dalDataContext.SubmitChanges();
                    return otp;
                }
                else
                {
                    return existingRequestee.Otp;
                }

            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(ex.Message),
                    new FaultReason("An Error occured While Creating New Requestee: " + ex.Message));
            }
        }
Ejemplo n.º 14
0
        public static void AddDefaultFeids(int EventID, DAL dalDataContext)
        {
            List<Field> ListField = new List<Field>();

            Field firstName = new Field();
            firstName.FieldName = firstName.FieldLabel = "First Name";
            Field lastName = new Field();
            lastName.FieldName = lastName.FieldLabel = "Last Name";
            firstName.IsRequired = lastName.IsRequired = true;
            Field email = new Field();
            email.FieldName = email.FieldLabel = "Email";
            email.IsRequired = email.IsRequired = true;

            ListField.Add(firstName);
            ListField.Add(lastName);
            ListField.Add(email);

            try
            {

                    for (int i = 0; i < ListField.Count; i++)
                    {
                        AddField(dalDataContext, EventID, ListField[i]);
                    }

                    dalDataContext.SubmitChanges();

            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Field, Please Try Again!"));
            }
        }
Ejemplo n.º 15
0
        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!"));
            }
        }
Ejemplo n.º 16
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
            }
        }
Ejemplo n.º 17
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!"));
            }
        }
Ejemplo n.º 18
0
        public static void AddBudgetItems(int BudgetId, List<Items> itemList)
        {
            DAL dalDataContext = new DAL();

            List<OptimizedBudgetItemsDetails> bItemList = new List<OptimizedBudgetItemsDetails>();
            try
            {
                foreach (Items item in itemList)
                {
                    OptimizedBudgetItemsDetails bItem = new OptimizedBudgetItemsDetails(
                        BudgetId, item.EventID, item.typeString, item.ItemName);
                    bItemList.Add(bItem);
                }

                Table<OptimizedBudgetItemsDetails> budItems = dalDataContext.optimizedBudgetItemDetails;
                budItems.InsertAllOnSubmit(bItemList);
                budItems.Context.SubmitChanges();
            }
            catch (TransactionAbortedException tAbortedex)
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Saving Optimal Budget List: " + tAbortedex.Message));
            }
            catch (Exception ex)
            {
                throw new FaultException<SException>(new SException(),
                  new FaultReason("An Error occured While Saving Optimal Budget List: " + ex.Message));
            }
        }
Ejemplo n.º 19
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!"));
            }
        }
Ejemplo n.º 20
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!"));
            }
        }
Ejemplo n.º 21
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!"));
            }
        }
Ejemplo n.º 22
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!"));
            }
        }
Ejemplo n.º 23
0
        public static void DeleteAllParticipant(int EventID, DAL dalDataContext)
        {
            //chk if user can do this anot
            try
            {
                // Participant p = GetParticipant(ParticipantID);
                List<Participant> participants = (from participant in dalDataContext.participants
                                                  where participant.EventID == EventID
                                                  select participant).ToList<Participant>();

                for (int i = 0; i < participants.Count; i++)
                {
                    dalDataContext.participants.DeleteOnSubmit(participants[i]);
                }

                dalDataContext.SubmitChanges();
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Clearing Participant, Please Try Again!"));
            }

            return;
        }
Ejemplo n.º 24
0
        public static bool AddFacilityBookingReqDetails(int reqID, List<FacilityBookingRequestDetails> reqDetails)
        {
            DAL dalDataContext = new DAL();
            bool complete;
            Table<FacilityBookingRequestDetails> facReqDetails = dalDataContext.facBookReqsDetails;
            try
            {
                //Remove this 2 lines to test scope rollback
                for (int i = 0; i < reqDetails.Count; i++)
                    reqDetails[i].Requestid = reqID;

                facReqDetails.InsertAllOnSubmit(reqDetails);
                facReqDetails.Context.SubmitChanges();

                complete = true;
            }
            catch (TransactionAbortedException tAbortedex)
            {
                complete = false;
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding Booking Request: " + tAbortedex.Message));
            }
            catch (Exception ex)
            {
                complete = false;
                throw new FaultException<SException>(new SException(),
                  new FaultReason("An Error occured While Adding Booking Request: " + ex.Message));
            }

            return complete;
        }
Ejemplo n.º 25
0
 public static List<User> searchUser(string name, string userid, EnumRoles r)
 {
     DAL dalDataContext = new DAL();
     List<User> uList;
     if (userid == null || userid.Length > 0)
     {
         if (r == EnumRoles.Nil)
         {
             uList = (from user in dalDataContext.users
                      where SqlMethods.Like(user.Name, "%" + name + "%") && user.UserID == userid
                      && !(from role in dalDataContext.sRole select role.UserID).Contains(user.UserID)
                      && !(from facAdm in dalDataContext.facAdmins select facAdm.UserID).Contains(user.UserID)
                      select user).ToList<User>();
         }
         else if (r == EnumRoles.Facility_Admin)
         {
             uList = (from user in dalDataContext.users
                      where SqlMethods.Like(user.Name, "%" + name + "%") && user.UserID == userid
                      && (from facAdm in dalDataContext.facAdmins select facAdm.UserID).Contains(user.UserID)
                      select user).ToList<User>();
         }
         else
         {
             uList = (from user in dalDataContext.users
                      from sysRole in dalDataContext.sRole
                      where SqlMethods.Like(user.Name, "%" + name + "%") && user.UserID == userid
                      && user.UserID == sysRole.UserID && sysRole.RoleLevel == r
                      select user).ToList<User>();
         }
     }
     else
     {
         if (r == EnumRoles.Nil)
         {
             uList = (from user in dalDataContext.users
                      where SqlMethods.Like(user.Name, "%" + name + "%")
                      && !(from role in dalDataContext.sRole select role.UserID).Contains(user.UserID)
                       && !(from facAdm in dalDataContext.facAdmins select facAdm.UserID).Contains(user.UserID)
                      select user).ToList<User>();
         }
         else if (r == EnumRoles.Facility_Admin)
         {
             uList = (from user in dalDataContext.users
                      from facAdm in dalDataContext.facAdmins
                      where SqlMethods.Like(user.Name, "%" + name + "%")
                      && user.UserID == facAdm.UserID
                      select user).ToList<User>();
         }
         else
         {
             uList = (from user in dalDataContext.users
                      from sysRole in dalDataContext.sRole
                      where SqlMethods.Like(user.Name, "%" + name + "%")
                      && user.UserID == sysRole.UserID && sysRole.RoleLevel == r
                      select user).ToList<User>();
         }
     }
     return uList;
 }
Ejemplo n.º 26
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));
                    }
                }
            }
        }
Ejemplo n.º 27
0
        public static ItemTypes AddItemType(int evid, string type, bool isImpt, DAL dalDataContext)
        {
            Table<ItemTypes> typeTable = dalDataContext.itemTypes;
            ItemTypes newItemType = new ItemTypes(evid, type, isImpt);

            typeTable.InsertOnSubmit(newItemType);
            typeTable.Context.SubmitChanges();
            return newItemType;
        }
 public static List<FacilityBookingConfirmed> GetEventConfirmedDetail(int eventID, DateTime day)
 {
     DAL dalDataContext = new DAL();
     List<FacilityBookingConfirmed> fbc = (from confirmed in dalDataContext.facConfirmedBookings
                                     where confirmed.EventID == eventID
                                     && confirmed.RequestStartDateTime.Date == day.Date
                                     select confirmed).ToList<FacilityBookingConfirmed>();
     return fbc;
 }
 public static FacilityBookingConfirmed GetConfirmedDetail(int reqID)
 {
     DAL dalDataContext = new DAL();
     FacilityBookingConfirmed fbc = (from confirmed in dalDataContext.facConfirmedBookings
                                     where confirmed.RequestID == reqID
                                     select confirmed).
                                     FirstOrDefault<FacilityBookingConfirmed>();
     return fbc;
 }
Ejemplo n.º 30
0
        public static Items AddItem(int eventID, string type, string name, int sat, decimal est, DAL dalDataContext)
        {
            Table<Items> itemTable = dalDataContext.items;
            Items newItem = new Items(eventID,type, name, sat, est);

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

            return newItem;
        }