Esempio n. 1
0
        public async Task SaveAsync(StudyType entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

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

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


                    timeLineContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
 private void MapForUpdateentity(StudyType entity, DA.StudyType daEntity)
 {
     daEntity.Id = entity.Id;
 }