コード例 #1
0
        public async Task <ActivityEnroll> CreateActivityAsync(ActivityEnroll activity)
        {
            var desc = "CreateActivity";

            await AddAsync(activity);

            // 缓存用户创建的活动
            await SetRelativeEntitysAsync <ActivityEnroll, UserInfo>(activity.UserInfoId, desc, activity);

            return(activity);
        }
コード例 #2
0
        public async Task <ActionResult <ApiResult <ActivityEnroll> > > Post([FromBody] ActivityEnroll activity, [FromServices] IUtilService util)
        {
            activity.Status = ActivityStatus.Doing;
            await Service.CreateActivityAsync(activity);

            // 活动创建成功,保存创建的地址
            var address = new Tuple <string, string, double, double>(activity.Location, activity.Address, activity.Lng, activity.Lat);
            await util.SetActivityAddressAsync(activity.UserInfoId, address);

            return(new ApiResult <ActivityEnroll> {
                Result = activity
            });
        }
コード例 #3
0
        public async Task <ActivityParticipant> JoinActivityAsync(ActivityParticipant participant, ActivityEnroll activity = null)
        {
            participant.JoinTime = DateTime.Now;
            await AddAsync(participant);

            if (activity == null)
            {
                activity = await GetAsync <ActivityEnroll>(participant.ActivityEnrollId);
            }
            else
            {
                Context.Attach(activity);
            }
            activity.Quantity++;
            if (participant.Status == JoinStatus.Join)
            {
                activity.JoinQuantity++;
            }
            else if (participant.Status == JoinStatus.Absent)
            {
                activity.AbsentQuantity++;
            }
            else if (participant.Status == JoinStatus.Pending)
            {
                activity.PendingQuantity++;
            }
            await Context.SaveChangesAsync();

            return(participant);
        }
コード例 #4
0
        public async Task <ActivityEnroll> CreateActivityAsync(ActivityEnroll activity)
        {
            await AddAsync(activity);

            return(activity);
        }
コード例 #5
0
        public async Task <ActionResult <ApiResult <ActivityEnroll> > > UpdateActivity(int id, [FromBody] ActivityEnroll activity)
        {
            var entity = await Service.GetAsync <ActivityEnroll>(id);

            entity.Title        = activity.Title;
            entity.ActivityTime = activity.ActivityTime;
            entity.Location     = activity.Location;
            entity.Address      = activity.Address;
            entity.Lng          = activity.Lng;
            entity.Lat          = activity.Lat;
            entity.Remark       = activity.Remark;
            await Service.UpdateAsync(entity, new[] { nameof(activity.Title), nameof(activity.ActivityTime), nameof(activity.Location), nameof(activity.Address), nameof(activity.Lng), nameof(activity.Lat), nameof(activity.Remark) });

            return(new ApiResult <ActivityEnroll> {
                Message = "ok"
            });
        }