Exemplo n.º 1
0
        public async Task <int> WriteOrUpdateUserinfo(int UserId, int Role, int Year, int Mounth)
        {
            var model = await base.BaseDal.GetModelAsync(x => x.UserId == UserId && x.Role == Role && x.Year == Year);

            RegisterInfo registerInfo = new RegisterInfo
            {
                UserId = UserId,
                Role   = Role,
                Year   = Year
            };

            if (model != null)
            {
                model = ChangeMounth(model, Mounth, true);
                return(await base.BaseDal.Modify(model));
            }

            var sysuser = await _sysUserService.GetModelAsync(x => x.Id == UserId);

            if (registerInfo.Role == 1)
            {
                registerInfo.Name = sysuser.UserName;
                registerInfo.PhoneNameDepartment = sysuser.Department;
            }
            if (registerInfo.Role == 2)
            {
                registerInfo.Name = sysuser.JobAddress;
                registerInfo.PhoneNameDepartment = sysuser.UserName;
                registerInfo.Undertaker          = sysuser.Undertaker;
                registerInfo.Phone = sysuser.UndertakerPhone;
            }
            if (registerInfo.Role == 3)
            {
                registerInfo.Name = sysuser.UserName;
                registerInfo.PhoneNameDepartment = sysuser.UserPhone;
            }

            registerInfo = ChangeMounth(registerInfo, Mounth, true);
            return(await BaseDal.AddModel(registerInfo));
        }