Exemplo n.º 1
0
        /// <summary>
        /// Generic method to support any Entity type.
        /// This method uses the BaseEntityRepository directly
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ctx"></param>
        /// <param name="jsonData"></param>
        /// <returns></returns>
        private T SaveUserEntity <T>(string listName, string jsonData) where T : IKPEntity, new()
        {
            T entity = JsonConvert.DeserializeObject <T>(jsonData);
            T item   = default(T);
            EntityRepository <T> repository = new EntityRepository <T>(this.spDataAccess, listName);

            if (entity.KPID == -1 || entity.KPID == 0)
            {
                item = repository.AddItem(entity);
            }
            else
            {
                item = repository.UpdateItem(entity);
            }

            return(item);
        }