Пример #1
0
 public int InitAccount(int iRequesterID, DTO.NewAccountData dtoItem, out Library.DTO.Notification notification)
 {
     return(factory.InitAccount(iRequesterID, dtoItem, out notification));
 }
Пример #2
0
        public object CustomFunction(int userId, string identifier, System.Collections.Hashtable input, out Library.DTO.Notification notification)
        {
            switch (identifier.ToLower())
            {
            case "getsearchfilter":
                return(bll.GetSearchFilter(userId, out notification));

            case "getinitdata":
                return(bll.GetInitData(userId, out notification));

            case "initaccount":
                if (!input.ContainsKey("AspNetUserId"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow id"
                    };
                    return(null);
                }
                if (!input.ContainsKey("EmployeeID"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow employee"
                    };
                    return(null);
                }
                if (!input.ContainsKey("IsActive"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow active status"
                    };
                    return(null);
                }
                if (!input.ContainsKey("UserGroupID"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow group"
                    };
                    return(null);
                }
                DTO.NewAccountData data = new DTO.NewAccountData();
                data.AspNetUserId = input["AspNetUserId"].ToString();
                data.EmployeeID   = (int?)input["EmployeeID"];
                data.IsActive     = Convert.ToBoolean(input["IsActive"]);
                data.UserGroupID  = (int)input["UserGroupID"];
                return(bll.InitAccount(userId, data, out notification));

            case "updateaccount":
                if (!input.ContainsKey("id"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow id"
                    };
                    return(null);
                }
                if (!input.ContainsKey("data"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow data"
                    };
                    return(null);
                }
                return(bll.UpdateAccount(userId, Convert.ToInt32(input["id"]), input["data"], out notification));

            case "updateemployee":
                if (!input.ContainsKey("id"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow id"
                    };
                    return(null);
                }
                if (!input.ContainsKey("data"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow data"
                    };
                    return(null);
                }
                return(bll.UpdateEmployee(userId, Convert.ToInt32(input["id"]), input["data"], out notification));

            case "updatepermission":
                if (!input.ContainsKey("id"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow id"
                    };
                    return(null);
                }
                if (!input.ContainsKey("data"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow data"
                    };
                    return(null);
                }
                return(bll.UpdatePermission(userId, Convert.ToInt32(input["id"]), input["data"], out notification));

            case "updatefactoryaccess":
                if (!input.ContainsKey("id"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow id"
                    };
                    return(null);
                }
                if (!input.ContainsKey("data"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow data"
                    };
                    return(null);
                }
                return(bll.UpdateFactoryAccess(userId, Convert.ToInt32(input["id"]), input["data"], out notification));

            case "forcechangepassword":
                if (!input.ContainsKey("id"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow id"
                    };
                    return(null);
                }
                return(bll.ForceChangePassword(userId, Convert.ToInt32(input["id"]), out notification));

            case "restoreuser":
                if (!input.ContainsKey("id"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow id"
                    };
                    return(null);
                }
                return(bll.RestoreUser(userId, Convert.ToInt32(input["id"]), out notification));

            case "get-api-key":
                if (!input.ContainsKey("id"))
                {
                    notification = new Library.DTO.Notification()
                    {
                        Type = Library.DTO.NotificationType.Error, Message = "Unknow id"
                    };
                    return(null);
                }
                return(bll.GetAPIKey(userId, Convert.ToInt32(input["id"]), out notification));
            }
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Error, Message = "Custom function's identifier not matched"
            };
            return(null);
        }