Exemplo n.º 1
0
        public async Task SaveAsync(Region entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

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

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


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