Esempio n. 1
0
        /// <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>());
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
        /// <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>());
        }
Esempio n. 4
0
 /// <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));
     }
 }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        //[ProducesResponseType(typeof(ScheduleGetDto), (int)HttpStatusCode.OK)]
        public IActionResult Put(int scheduleId, [FromBody] ScheduleEditDto scheduleEditDto)
        {
            var schedule = _scheduleRepository.EditSchedule(scheduleId, scheduleEditDto);

            return(Ok(schedule));
        }