コード例 #1
0
        public async Task SaveAsync(SubjectMarkInfo entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

                using (var timeLineContext = _contextFactory.GetTimeLineContext())
                {
                    var entityModel = await timeLineContext
                                      .SubjectMarkInfos
                                      .FirstOrDefaultAsync(item => item.Id.Equals(entity.Id));

                    if (entityModel == null)
                    {
                        entityModel = new DA.SubjectMarkInfo();
                        MapForUpdateentity(entity, entityModel);
                        await timeLineContext.SubjectMarkInfos.AddAsync(entityModel);
                    }
                    else
                    {
                        MapForUpdateentity(entity, entityModel);
                    }


                    timeLineContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
 public async Task <IActionResult> Put([FromBody] SubjectMarkInfo value)
 {
     try
     {
         var entity = _mapper.Map <BL.SubjectMarkInfo>(value);
         var id     = _service.SaveAsync(entity);
         return(Ok(id));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
コード例 #3
0
 private void MapForUpdateentity(SubjectMarkInfo entity, DA.SubjectMarkInfo daEntity)
 {
     daEntity.Id = entity.Id;
 }