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

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

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


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