Example #1
0
 /// <summary>
 /// 更改部分员工信息
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="NewUserInfo"></param>
 /// <returns></returns>
 public ReturnViewModel <IActionResult> setUserInfo(string userId, UserInfoViewModel NewUserInfo)
 {
     try
     {
         var oldUser = db.AspNetUsers.Where(x => x.Id == userId).FirstOrDefault();
         oldUser.RealName     = NewUserInfo.RealName;
         oldUser.Sex          = NewUserInfo.Sex;
         oldUser.Address      = NewUserInfo.Address;
         oldUser.Birthday     = NewUserInfo.Birthday;
         oldUser.PhoneNumber  = NewUserInfo.PhoneNumber;
         oldUser.Introduction = NewUserInfo.Introduction;
         db.SaveChangesAsync();
     }
     catch (Exception)
     {
         return(new ReturnViewModel <IActionResult>()
         {
             code = (int)codes.TokenOrInfoError, message = "token或者信息格式不正确"
         });
     }
     return(new ReturnViewModel <IActionResult>()
     {
         code = (int)codes.Success, message = "个人信息更改成功"
     });
 }
        public async Task <bool> Create([FromBody] User user)
        {
            if (ModelState.IsValid)
            {
                _hrcContext.Add(user);
                try
                {
                    await _hrcContext.SaveChangesAsync();

                    return(true);
                }
                catch (DbUpdateException)
                {
                    return(false);
                }
            }

            return(false);
        }
        public async Task <bool> Create([FromBody] Workout workout)
        {
            if (ModelState.IsValid)
            {
                workout.Id = Guid.NewGuid().ToString();
                _hrcContext.Add(workout);
                try
                {
                    await _hrcContext.SaveChangesAsync();

                    return(true);
                }
                catch (DbUpdateException)
                {
                    return(false);
                }
            }

            return(false);
        }
Example #4
0
        /// <summary>
        /// 签到
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public ReturnViewModel <bool> Checkin(NewUser user)
        {
            var time = DateTime.Now;

            db.AttendanceSheet.Add(new AttendanceSheet
            {
                UserId              = user.Id,
                RealName            = user.RealName,
                AttendanceStartTime = time.Date,
                DepartmentId        = user.DepartmentId,
                ClockTime           = time,
                AttendanceType      = SigninModel.FormatType(time)
            });
            db.SaveChangesAsync();
            return(new ReturnViewModel <bool>()
            {
                code = (int)codes.Success,
                message = "签到成功"
            });
        }