public BaseResponse SignActivity(ActivitySignFileter request) { BaseResponse response = new BaseResponse(); var activityRepository = unitOfWork.GetRepository <DC_GroupActivityRecord>(); var activityList = activityRepository.dbSet.Where(a => a.ID == request.ActivityID || a.CreateFromID == request.ActivityID).ToList(); var activity = activityList.Where(a => DateTime.Today.CompareTo(a.StartTime.Value.Date) == 0).FirstOrDefault(); unitOfWork.BeginTransaction(); if (activity == null) { activity = activityList.Where(a => a.ID == request.ActivityID).FirstOrDefault(); if (activity != null) { DC_GroupActivityRecord newActivity = new DC_GroupActivityRecord(); newActivity.CategoryID = activity.CategoryID; newActivity.ItemID = activity.ItemID; newActivity.ActivityName = activity.ActivityName; newActivity.ActivityContent = activity.ActivityContent; newActivity.ActivityPlace = activity.ActivityPlace; newActivity.StartTime = DateTime.Now; newActivity.AreaID = activity.AreaID; newActivity.OrganizationID = activity.OrganizationID; newActivity.CreateFromID = request.ActivityID; activity = newActivity; } else { response.IsSuccess = false; response.ResultMessage = "活动信息不存在,请联系管理员。"; return(response); } } else { if (!string.IsNullOrEmpty(activity.EmployeeIDs) && request.UserType == Enum.GetName(typeof(UserType), UserType.Employee) && ("," + activity.EmployeeIDs + ",").IndexOf("," + request.UserID.ToString() + ",") != -1) { response.IsSuccess = false; response.ResultMessage = "你已签到过,请勿重复签到。"; return(response); } if (!string.IsNullOrEmpty(activity.MemberIDs) && request.UserType == Enum.GetName(typeof(UserType), UserType.Resident) && ("," + activity.MemberIDs + ",").IndexOf("," + request.UserID.ToString() + ",") != -1) { response.IsSuccess = false; response.ResultMessage = "你已签到过,请勿重复签到。"; return(response); } } if (request.UserType == Enum.GetName(typeof(UserType), UserType.Employee)) { if (!string.IsNullOrEmpty(activity.EmployeeIDs)) { activity.EmployeeIDs += "," + request.UserID; activity.EmployeeNames += "," + request.UserName; activity.EmployeeCount += 1; } else { activity.EmployeeIDs = request.UserID.ToString();; activity.EmployeeNames = request.UserName; activity.EmployeeCount = 1; } } else { if (!string.IsNullOrEmpty(activity.MemberIDs)) { activity.MemberIDs += "," + request.UserID; activity.MemberNames += "," + request.UserName; activity.MemberCount += 1; } else { activity.MemberIDs = request.UserID.ToString();; activity.MemberNames = request.UserName; activity.MemberCount = 1; } } if (activity.ID == 0) { activityRepository.Insert(activity); } else { activityRepository.Update(activity); } unitOfWork.Commit(); return(response); }
public IHttpActionResult SignActivity([FromBody] ActivitySignFileter request) { var response = service.SignActivity(request); return(Ok(response)); }