/// <summary> /// 新增Schedule /// </summary> protected virtual async Task <ScheduleEditDto> CreateScheduleAsync(ScheduleEditDto input) { var entity = input.MapTo <Schedule>(); //ObjectMapper.Map<Schedule>(input); await _scheduleRepository.InsertAsync(entity); return(entity.MapTo <ScheduleEditDto>()); }
/// <summary> /// 删除计划信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task ScheduleDeleteByIdAsync(ScheduleEditDto input) { await _scheduleRepository.DeleteAsync(input.Id.Value); //var entity = await _scheduleRepository.GetAsync(input.Id.Value); //input.MapTo(entity); //entity.IsDeleted = true; //entity.DeletionTime = DateTime.Now; //entity.DeleterUserId = AbpSession.UserId; //await _scheduleRepository.UpdateAsync(entity); }
/// <summary> /// 编辑Schedule /// </summary> protected virtual async Task <ScheduleEditDto> UpdateScheduleAsync(ScheduleEditDto input) { var entity = await _scheduleRepository.GetAsync(input.Id.Value); input.MapTo(entity); // ObjectMapper.Map(input, entity); var result = await _scheduleRepository.UpdateAsync(entity); return(result.MapTo <ScheduleEditDto>()); }
/// <summary> /// 新增或修改计划信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <ScheduleEditDto> CreateOrUpdateScheduleAsycn(ScheduleEditDto input) { if (input.Status == ScheduleMasterStatusEnum.已发布) { input.PublishTime = DateTime.Now; } if (input.Id.HasValue) { return(await UpdateScheduleAsync(input)); } else { return(await CreateScheduleAsync(input)); } }
/// <summary> /// MPA版本才会用到的方法 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <GetScheduleForEditOutput> GetScheduleForEdit(NullableIdDto <Guid> input) { var output = new GetScheduleForEditOutput(); ScheduleEditDto scheduleEditDto; if (input.Id.HasValue) { var entity = await _scheduleRepository.GetAsync(input.Id.Value); scheduleEditDto = entity.MapTo <ScheduleEditDto>(); //scheduleEditDto = ObjectMapper.Map<List <scheduleEditDto>>(entity); } else { scheduleEditDto = new ScheduleEditDto(); } output.Schedule = scheduleEditDto; return(output); }
public ScheduleGetDto EditSchedule(int scheduleId, ScheduleEditDto scheduleEditDto) { var schedule = _context.Set <Schedule>().Find(scheduleId); schedule.UserId = scheduleEditDto.UserId; schedule.AvailabilityId = scheduleEditDto.AvailabilityId; schedule.PositionId = scheduleEditDto.PositionId; _context.SaveChanges(); var scheduleGetDto = new ScheduleGetDto { Id = schedule.Id, UserId = schedule.UserId, AvailabilityId = schedule.AvailabilityId, PositionId = schedule.PositionId }; scheduleGetDto.Id = schedule.Id; return(scheduleGetDto); }
//[ProducesResponseType(typeof(ScheduleGetDto), (int)HttpStatusCode.OK)] public IActionResult Put(int scheduleId, [FromBody] ScheduleEditDto scheduleEditDto) { var schedule = _scheduleRepository.EditSchedule(scheduleId, scheduleEditDto); return(Ok(schedule)); }