예제 #1
0
        public static bool UsertEnterpriseUserConfig(EnterpriseUserViewModel data, string user)
        {
            var result = false;

            try
            {
                using (var dbhelper = new SqlDbHelper(BeautyServicePackageDal.GetTuhuGrouponWriteConnstr()))
                {
                    dbhelper.BeginTransaction();
                    var userConfig   = BeautyServicePackageDal.SelectEnterpriseUserConfigByUserId(dbhelper, data.UserId);
                    var moduleConfig = BeautyServicePackageDal.SelectEnterpriseUserModuleConfigByUserId(dbhelper, data.UserId);
                    if (userConfig != null && userConfig.Any())
                    {
                        BeautyServicePackageDal.DeleteEnterpriseUserConfigByUserId(dbhelper, data.UserId);
                    }
                    if (moduleConfig != null && moduleConfig.Any())
                    {
                        BeautyServicePackageDal.DeleteEnterpriseModuleConfigByUserId(dbhelper, data.UserId);
                    }
                    if (data.PackageDetailIds != null && data.PackageDetailIds.Any())
                    {
                        foreach (var item in data.PackageDetailIds)
                        {
                            BeautyServicePackageDal.InsertEnterpriseUserConfig(dbhelper, data.UserId, item, data.Remark);
                        }
                    }
                    else
                    {
                        BeautyServicePackageDal.InsertEnterpriseUserConfig(dbhelper, data.UserId, 0, data.Remark);//允许不配服务模板
                    }
                    if (data.UserModuleDetails != null && data.UserModuleDetails.Any())
                    {
                        foreach (var item in data.UserModuleDetails)
                        {
                            BeautyServicePackageDal.InsertEnterpriseUserModuleConfig(dbhelper, data.UserId, item.ModuleType);
                        }
                    }
                    dbhelper.Commit();
                    result = true;
                    var log = new BaoYangOprLog
                    {
                        LogType     = "EnterpriseUserConfig",
                        IdentityID  = data.UserId.ToString(),
                        OldValue    = "[]",
                        NewValue    = JsonConvert.SerializeObject(data),
                        Remarks     = $"发码服务权限修改 {data.UserMobile}",
                        OperateUser = user,
                    };
                    LoggerManager.InsertLog("BeautyOprLog", log);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
            }

            return(result);
        }