Exemple #1
0
        public async Task SaveAsync(Place entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

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

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


                    timeLineContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
 private void MapForUpdateentity(Place entity, DA.Place daEntity)
 {
     daEntity.Id = entity.Id;
 }