• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DataAccess.DAL类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中evmsService.DataAccess.DAL的典型用法代码示例。如果您正苦于以下问题:C# DAL类的具体用法?C# DAL怎么用?C# DAL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DAL类属于evmsService.DataAccess命名空间,在下文中一共展示了DAL类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CancelRequest

        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);
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:32,代码来源:RequestController.cs


示例2: AddService

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:33,代码来源:ServiceController.cs


示例3: DeleteParticipant

        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!"));
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:29,代码来源:ParticipantController.cs


示例4: AddRightsTemplate

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:30,代码来源:RoleTemplateLogicController.cs


示例5: GetLastNotification

        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 "";
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:27,代码来源:NotificationController.cs


示例6: AddRight

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:26,代码来源:RightController.cs


示例7: EditRole

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:30,代码来源:RoleController.cs


示例8: DeleteReview

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:27,代码来源:ReviewController.cs


示例9: AddFieldAnswer

 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!"));
     }
 }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:29,代码来源:FieldAnswer.cs


示例10: DeleteTask

        //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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:27,代码来源:TaskController.cs


示例11: authenticate

        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;
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:32,代码来源:UserController.cs


示例12: AddRoleTemplate

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:25,代码来源:RoleTemplateController.cs


示例13: CreateNewRequestee

        //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));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:34,代码来源:RequesteeController.cs


示例14: AddDefaultFeids

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:34,代码来源:FieldController.cs


示例15: SetBought

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:32,代码来源:BudgetDetailsController.cs


示例16: DeleteProgram

        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
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:27,代码来源:ProgramController.cs


示例17: AddRoleAndRights

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:32,代码来源:RoleLogicController.cs


示例18: AddBudgetItems

        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));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:29,代码来源:BudgetDetailsController.cs


示例19: DeleteEvent

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:27,代码来源:EventController.cs


示例20: DeleteGuest

        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!"));
            }
        }
开发者ID:allanckw,项目名称:GEMS-Web,代码行数:26,代码来源:GuestController.cs



注:本文中的evmsService.DataAccess.DAL类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# entities.User类代码示例发布时间:2022-05-26
下一篇:
C# Model.StationContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap