コード例 #1
0
        public BaseResponse <bool> AddOrganizationRecord(AddOrganParameter param)
        {
            BaseResponse <bool> response = new BaseResponse <bool>();

            try
            {
                Organization organ = new Organization();
                organ.OrganCode        = param.OrganCode;
                organ.OrganFullName    = param.OrganFullName;
                organ.OrganShortName   = param.OrganShortName;
                organ.OrganTypeID      = param.OrganTypeID;
                organ.AddUserID        = param.AddUserID;
                organ.LastUpdateDate   = DateTime.Now;
                organ.LastUpdateUserID = param.AddUserID;

                var operResult = organRepository.AddNew <Organization>(organ);
                if (operResult.ResultType != EnumOperationResultType.Success)
                {
                    throw new Exception("单位添加发生异常!");
                }
                response.IsSuccessful = true;
                response.Result       = true;
                return(response);
            }
            catch (Exception e)
            {
                response.IsSuccessful = false;
                response.Code         = "000000";
                response.Reason       = e.Message;

                return(response);
            }
        }
コード例 #2
0
        public BaseResponse <bool> AddOrganizationRecord(AddOrganParameter param)
        {
            if (Validate(param))
            {
                return(organManager.AddOrganizationRecord(param));
            }
            else
            {
                BaseResponse <bool> response = new BaseResponse <bool>();
                response.IsSuccessful = false;
                response.Reason       = "JWT_ERR";

                return(response);
            }
        }
コード例 #3
0
        public BaseResponse <bool> AddOrganizationRecord(AddOrganParameter param)
        {
            BaseResponse <bool> response = new BaseResponse <bool>();

            try
            {
                #region 输入验证
                if (string.IsNullOrEmpty(param.OrganCode))
                {
                    response.IsSuccessful = false;
                    response.Reason       = "单位编码不能为空";
                    return(response);
                }
                if (string.IsNullOrEmpty(param.OrganFullName))
                {
                    response.IsSuccessful = false;
                    response.Reason       = "单位全称不能为空";
                    return(response);
                }

                if (param.OrganFullName.Length > 20)
                {
                    response.IsSuccessful = false;
                    response.Reason       = "单位全称不能超过20个字符";
                    return(response);
                }

                if (param.OrganTypeID < 1)
                {
                    response.IsSuccessful = false;
                    response.Reason       = "请选择单位类型";
                    return(response);
                }
                //if (string.IsNullOrEmpty(param.OrganShortName))
                //{
                //    response.IsSuccessful = false;
                //    response.Reason = "单位简称不能为空";
                //    return response;
                //}
                //if (param.OrganShortName.Length > 10)
                //{
                //    response.IsSuccessful = false;
                //    response.Reason = "单位简称不能超过10个字符";
                //    return response;
                //}

                var isExisted = organRepository.GetDatas <Organization>(t => !t.IsDeleted && !string.IsNullOrEmpty(t.OrganCode) && t.OrganCode.Equals(param.OrganCode), true).Any();
                if (isExisted)
                {
                    response.IsSuccessful = false;
                    response.Reason       = "单位编码已存在";
                    return(response);
                }

                isExisted = organRepository.GetDatas <Organization>(t => !t.IsDeleted && !string.IsNullOrEmpty(t.OrganFullName) && t.OrganFullName.Equals(param.OrganFullName), true).Any();
                if (isExisted)
                {
                    response.IsSuccessful = false;
                    response.Reason       = "单位全称已存在";
                    return(response);
                }

                //isExisted = organRepository.GetDatas<Organization>(t => !t.IsDeleted && !string.IsNullOrEmpty(t.OrganShortName) && t.OrganShortName.Equals(param.OrganShortName), true).Any();
                //if (isExisted)
                //{
                //    response.IsSuccessful = false;
                //    response.Reason = "单位简称已存在";
                //    return response;
                //}
                #endregion

                Organization organ = new Organization();
                organ.OrganCode     = param.OrganCode;
                organ.OrganFullName = param.OrganFullName;
                //organ.OrganShortName = param.OrganShortName;
                organ.OrganTypeID = param.OrganTypeID;

                //organ.AreaID = param.AreaID;
                organ.AddUserID        = param.AddUserID;
                organ.LastUpdateDate   = DateTime.Now;
                organ.LastUpdateUserID = param.AddUserID;

                var operResult = organRepository.AddNew <Organization>(organ);
                if (operResult.ResultType != EnumOperationResultType.Success)
                {
                    throw new Exception("单位添加发生异常!");
                }
                response.IsSuccessful = true;
                response.Result       = true;

                #region 操作日志
                new LogManager().AddOperationLog(param.CurrentUserID, "添加部门", param.RequestIP);
                #endregion

                return(response);
            }
            catch (Exception e)
            {
                response.IsSuccessful = false;
                response.Code         = "000000";
                response.Reason       = e.Message;

                return(response);
            }
        }
コード例 #4
0
 public BaseResponse <bool> AddOrganizationRecord(AddOrganParameter param)
 {
     return(organManager.AddOrganizationRecord(param));
 }