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

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

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


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